'use strict';

if (typeof jQuery === "undefined") {
	throw new Error("需要引入jQuery");
}

var hover ="";
var picName = "";
var imgPath = "";
var systemMenusArr =[];//顶部导航--系统管理
var otherId = ""; //存放其他任务左边菜单li的id
var casId = ""; //存放用例库左边菜单li的id
var interfaceId = "";//存放接口菜单li的id
var pwdFlag01 = '0'; 
var oldPwdFlag02 = '0';
var flagP = "";
var menus = new Object();
//项目任务标识、项目测试标识、项目迭代标识、系统设置标识
var taskFlg=0;
var sysTestFlg=0;
var inerfaceFlg=0;
var sysDieFlg=0;
var sysConfigFlg=0;
var projectTo=0;
var env = 0;
var intt;
var enterKey="";
var onlyOneTaskId = "";
var onlyOneTaskName = "";
//全局变量 pagesize pageList
var pageSize = 10;
var pageList = [10,30,50,100];
// 缓存全局变量及dom元素
var mainObjs = {
	tableHeight: window.innerHeight -171,
	$body: $("body"),
	$menu: $("#menu"),
	$homeMenu: $("#home_menu").parent('li'),
//	$treeArea: $(".tree-area"),
	$wrapPage: $("#wrap-page"),
	$switchBtn: $(".switch-btn"),
	$addOrEditWin: $("#addOrEditWinUserInfo"),
	$addOrEditForm: $("#addOrEditFormUserInfo"),
	$logoImg:$(".sidebary"),
	$systemM:$('#systemM'),
	$systemMenu:$("#systemMenu"),
	$ldapConfigInfoWin:$("#ldapConfigInfoWin"),
	$ldapConfigInfoForm:$("#ldapConfigInfoForm")
};
var buttons;
$(function() {
	$.parser.parse();
	//事先加载js，防止以后出现easyui组件加载未完成造成的问题
	exuiloader.load('datebox', null, true);
	exuiloader.load('layout', null, true);
	buttons = $.extend([], $.fn.datebox.defaults.buttons);
	buttons.splice(1, 0, {
	    text: '清空',
	    handler: function (target) {
	        $(target).datebox('setValue', '').datebox('hidePanel');
	    }
	});

	$("#loginNames").html("&emsp;"+$("#userName").val()+",你好！");
	//获取权限
	getLoginUserProManager();
	//首页的设置，无首页弹窗选择具体项目
	var flg = showHomePageWin();
	flagP = $("#projectFlag").val();
	if(flg){
		var myHomeUrls = $("#loginData").data("loginData")["dto.user"].myHome;
		var myUrlSplitR = myHomeUrls.split('&')[0]; 
		if(myHomeUrls!=undefined&&myHomeUrls!=""){
			if(privilegeMap[myUrlSplitR]!="1" && myHomeUrls.indexOf("otherMission") == -1 && myHomeUrls.indexOf("apiManager") == -1){
				logoEvent();
				tipPermission('您设置的首页所对应的权限己被收回，请联系管理员！');
				//return;
			}
		}
		if(flg){
			//加载左边菜单及效果
			loadLeftMenus();
		}else{
			$("#leftMenu").hide();
			$("#wrap-page").removeClass();
			tipPermission("首页url参数格式不匹配！");
		}
	}else{
		if(flagP!="1"){//没有参与任何项目
			//加载新用户，没参与项目
			var noHtml = newUserLoadMenu();
			mainObjs.$menu.append(noHtml);
			loadLeftMenus();
		}else{//参与了项目
			//加载左边菜单及效果
			loadLeftMenus();
		}

	}
	var sysContent = $.trim($('#systemM').html());
	if(sysContent==""){
		$("#systemMenu").hide();
	}
	//收缩按钮的移动样式
	sidebaryHover();
	//导航栏菜单的样式
	navMenueS();
	//判断是否为管理员，为管理员，显示测试用例库左边入库审核菜单
	if($("#isAdmin").text() == "2" || $("#isAdmin").text() == "1"){
		$("#l3").show();
		$("#l2").show();
	}else{
		$("#l3").hide();
	}
	if($("#loginName").text() != "admin"){
		$("body").find("li[idValue='upDb']").hide();
	}
	if($("#loginName").text() != "admin"){
		$("body").find("li[idValue='removeDemoData']").hide();
	}
	//监听session是否过期，如果过期，则跳到登录页面
	$.ajaxSetup({
        contentType:"application/x-www-form-urlencoded;charset=utf-8",
        beforeSend:function(XMLHttpRequest){
        	XMLHttpRequest.setRequestHeader("Accept-Language", "zh-CN,zh;q=0.8");
        },
        complete:function(XMLHttpRequest,textStatus){
            //通过XMLHttpRequest取得响应头，sessionstatus，
            var sessionstatus=XMLHttpRequest.getResponseHeader("sessionstatus");
            if(sessionstatus=="timeout"){
                //如果超时就处理 ，指定要跳转的页面(比如登陆页)
            	$.xconfirm({
            		msg:'会话超时，请返回登录页面',
            		okFn: function() {
            			window.parent.location.href= baseUrl + "/login.htm";
            		}
            	});
            }
         }
      });
	//自定义只能输入正数的方法
    $.extend($.fn.validatebox.defaults.rules, {
        zhengshu: {
    		validator: function(value){
    			var par = /^\d+$/;
    			return par.test(value);
    		},
    		message: '请输入非负整数'
        }
    });
  //自定义0到100的数字
    $.extend($.fn.validatebox.defaults.rules, {
        lessThan: {
    		validator: function(value){
    			var par = /^100$|^(\d|[1-9]\d)(\.\d+)*$/;
    			return par.test(value);
    		},
    		message: '请输入0到100的数'
        }
    });
    
    
    //回车键查询
    document.onkeydown=function(event){
		var e = event || window.event || arguments.callee.caller.arguments[0];
		if(e && e.keyCode==13){ // 按 Esc
			enterKey = "noData";
			searchChangeProject();
		}
	};
	//密码input绑定事件
	notAllowInput();
});

//过滤项目
function searchChangeProject(){
	$("#caseItemList").xdatagrid('load', {
		'dto.singleTest.proName':$("#changeProjectName").val()
	});
}


//加载左边菜单及效果
function loadLeftMenus(){
	
	$.ajaxSettings.async = false;
	$.getJSON(
			baseUrl + "/navigate?reload=1",
			function(data) {
				var html = '',a ='',b='',c='',d='',e='';
				var navTopHtml = "";  //保存动态顶部导航栏--系统管理的html
				if (data && data.length!=0) {
					flagP = $("#projectFlag").val();
					$.each(data, function(i, v) {
						if(flagP!="1"){
							if(v.functionId=="68"||v.functionId=="87"||v.functionId=="107"||v.functionId=="143" ||v.functionId=="11" || v.functionId=="13"){
								menus["menu_"+v.functionId] = v;
							}
						}else if(flagP=="1" && $("#haveProject").val() == "1"){
							if(v.functionId=="68"||v.functionId=="87"||v.functionId=="107"||v.functionId=="143" ||v.functionId=="11" || v.functionId=="13"){
								menus["menu_"+v.functionId] = v;
								if(v.functionId=="68"){
									html += '<li id="menu_'+v.functionId+'" data-info="'+v.functionId+'" class="treeview">'
									+'<a href="javascript:void(0);" title='+v.functionName+' class="firstA">'
									+'<img class="" src="'+baseUrl+'/itest/images/homeImage/projectMan1.png">&nbsp;&nbsp;&nbsp;'
									+'<span class="">' + v.functionName + '&nbsp;&nbsp;</span>'
									+'</a></li>';
								}else if(v.functionId=="87"){
									html += '<li id="menu_'+v.functionId+'" data-info="'+v.functionId+'" class="treeview">'
									+'<a href="javascript:void(0);" title='+v.functionName+' class="firstA">'
									+'<img class="" src="'+baseUrl+'/itest/images/homeImage/testSin1.png">&nbsp;&nbsp;&nbsp;'
									+'<span class="">' + v.functionName + '&nbsp;&nbsp;</span>'
									+'</a></li>';
								}else if(v.functionId=="107"){
									html += '<li id="menu_'+v.functionId+'" data-info="'+v.functionId+'" class="treeview">'
									+'<a href="javascript:void(0);" title='+v.functionName+' class="firstA">'
									+'<img class="" src="'+baseUrl+'/itest/images/homeImage/defect1.png">&nbsp;&nbsp;&nbsp;'
									+'<span class="">' + v.functionName + '&nbsp;&nbsp;</span>'
									+'</a></li>';
								}else if(v.functionId=="143"){
									html += '<li id="menu_'+v.functionId+'" data-info="'+v.functionId+'" class="treeview">'
									+'<a href="javascript:void(0);" title='+v.functionName+' class="firstA">'
									+'<img class="" src="'+baseUrl+'/itest/images/homeImage/analysis1.png">&nbsp;&nbsp;&nbsp;'
									+'<span class="">' + v.functionName + '&nbsp;&nbsp;</span>'
									+'</a></li>';
								}else if(v.functionId=="11"){
									html += '<li id="menu_'+v.functionId+'" data-info="'+v.functionId+'" class="treeview">'
									+'<a href="javascript:void(0);" title='+v.functionName+' class="firstA">'
									+'<img class="" src="'+baseUrl+'/itest/images/homeImage/testcasepkg1.png">&nbsp;&nbsp;&nbsp;'
									+'<span class="">' + v.functionName + '&nbsp;&nbsp;</span>'
									+'</a></li>';
								}else if(v.functionId=="13"){
									html += '<li id="menu_'+v.functionId+'" data-info="'+v.functionId+'" class="treeview" >'
									+'<a href="javascript:void(0);" title='+v.functionName+' class="firstA">'
									+'<img class="" src="'+baseUrl+'/itest/images/homeImage/zl1.png">&nbsp;&nbsp;&nbsp;'
									+'<span class="">' + v.functionName + '&nbsp;&nbsp;</span>'
									+'</a></li>';
								}
							}
							
						}else if(flagP=="1" && $("#haveProject").val() == "0"){
							if(v.functionId=="68"||v.functionId=="87"||v.functionId=="107"||v.functionId=="143" ||v.functionId=="11" || v.functionId=="13"){
								menus["menu_"+v.functionId] = v;
								if(v.functionId=="68"){
									html += '<li id="menu_'+v.functionId+'" data-info="'+v.functionId+'" class="treeview disabled">'
									+'<a href="javascript:void(0);" title='+v.functionName+' class="firstA">'
									+'<img class="" src="'+baseUrl+'/itest/images/homeImage/projectMan1.png">&nbsp;&nbsp;&nbsp;'
									+'<span class="">' + v.functionName + '&nbsp;&nbsp;</span>'
									+'</a></li>';
								}else if(v.functionId=="87"){
									html += '<li id="menu_'+v.functionId+'" data-info="'+v.functionId+'" class="treeview disabled">'
									+'<a href="javascript:void(0);" title='+v.functionName+' class="firstA">'
									+'<img class="" src="'+baseUrl+'/itest/images/homeImage/testSin1.png">&nbsp;&nbsp;&nbsp;'
									+'<span class="">' + v.functionName + '&nbsp;&nbsp;</span>'
									+'</a></li>';
								}else if(v.functionId=="107"){
									html += '<li id="menu_'+v.functionId+'" data-info="'+v.functionId+'" class="treeview disabled">'
									+'<a href="javascript:void(0);" title='+v.functionName+' class="firstA">'
									+'<img class="" src="'+baseUrl+'/itest/images/homeImage/defect1.png">&nbsp;&nbsp;&nbsp;'
									+'<span class="">' + v.functionName + '&nbsp;&nbsp;</span>'
									+'</a></li>';
								}else if(v.functionId=="143"){
									html += '<li id="menu_'+v.functionId+'" data-info="'+v.functionId+'" class="treeview disabled">'
									+'<a href="javascript:void(0);" title='+v.functionName+' class="firstA">'
									+'<img class="" src="'+baseUrl+'/itest/images/homeImage/analysis1.png">&nbsp;&nbsp;&nbsp;'
									+'<span class="">' + v.functionName + '&nbsp;&nbsp;</span>'
									+'</a></li>';
								}else if(v.functionId=="11"){
									html += '<li id="menu_'+v.functionId+'" data-info="'+v.functionId+'" class="treeview disabled">'
									+'<a href="javascript:void(0);" title='+v.functionName+' class="firstA">'
									+'<img class="" src="'+baseUrl+'/itest/images/homeImage/testcasepkg1.png">&nbsp;&nbsp;&nbsp;'
									+'<span class="">' + v.functionName + '&nbsp;&nbsp;</span>'
									+'</a></li>';
								}else if(v.functionId=="13"){
									html += '<li id="menu_'+v.functionId+'" data-info="'+v.functionId+'" class="treeview disabled">'
									+'<a href="javascript:void(0);" title='+v.functionName+' class="firstA">'
									+'<img class="" src="'+baseUrl+'/itest/images/homeImage/zl1.png">&nbsp;&nbsp;&nbsp;'
									+'<span class="">' + v.functionName + '&nbsp;&nbsp;</span>'
									+'</a></li>';
								}
							}
						}
						
						//顶部导航栏--系统管理
						if(v.functionId=="3"||v.functionId=="20"||v.functionId=="25"||v.functionId=="44"||v.functionId=="93"){
							systemMenusArr[i] = v;
							if(v.functionId=="3"){
								a = "<li class='systemMLine' id='system_" + i +"'><a tabindex='-1' href='javascript:void(0);'>用户管理</a></li>";
					
							}
							if(v.functionId=="20"){
								b = "<li  class='systemMLine' id='system_" + i +"'><a tabindex='-1' href='javascript:void(0);'>用户组管理</a></li>";
					
							}
							if(v.functionId=="25"){
								c = "<li  class='systemMLine' id='system_" + i +"'><a tabindex='-1' href='javascript:void(0);'>权限管理</a></li>";
					
							}
							if(v.functionId=="44"){
							
								d = "<li  class='systemMLine' id='system_" + i +"'><a tabindex='-1' href='javascript:void(0);'>基础字典维护</a></li>";
					
							}

						}
					});
					
					if(flagP!="0" && $("#haveProject").val() == "1"){
						
						html += '<li id="menu_s" data-info="" class="treeview">'
							+'<a href="javascript:void(0);" title="设置首页" class="firstA">'
							+'<img class="" src="'+baseUrl+'/itest/images/homeImage/myHome1.png">&nbsp;&nbsp;&nbsp;'
							+'<span class="">设置首页&nbsp;&nbsp;</span>'
							+'</a></li>';
					}
				
					//用例库移至系统设置下，修改
					var testLib ="";
					if($("#isAdmin").text()=="1" && $("#loginName").text()=="admin"){
						testLib ="<li class='systemMLine' idValue='caseLib'><a tabindex=\"-1\" href=\"javascript:void(0);\">用例库</a></li>"+
						"<li class='systemMLine' idValue='upDb'><a tabindex=\"-1\" href=\"javascript:void(0);\">升级数据库</a></li>"+
						"<li class='systemMLine' idValue='ldapServerConfig'><a tabindex=\"-1\" href=\"javascript:void(0);\">LDAP服务配置</a></li>"+
						"<li class='systemMLine' idValue='ldapAccountSyn'><a tabindex=\"-1\" href=\"javascript:void(0);\">LDAP账户同步</a></li>"+
						"<li class='systemMLine' idValue='removeDemoData'><a tabindex=\"-1\" href=\"javascript:void(0);\">清除demo数据</a></li>";
					}else{
						testLib ="<li class='systemMLine' idValue='caseLib'><a tabindex=\"-1\" href=\"javascript:void(0);\">用例库</a></li>"+
						"<li class='systemMLine' idValue='upDb'><a tabindex=\"-1\" href=\"javascript:void(0);\">升级数据库</a></li>"+
						"<li class='systemMLine' idValue='removeDemoData'><a tabindex=\"-1\" href=\"javascript:void(0);\">清除demo数据</a></li>";
					}
					
					navTopHtml = a+b+c+d+e+testLib;
					mainObjs.$systemM.empty();
					mainObjs.$systemM.append(navTopHtml);
					mainObjs.$menu.append(html);
					mainObjs.$menu.data('menus', menus);
					init();
					hoverEvent();
					//顶部导航栏--系统管理二级菜单绑定点击事件
					bindSystemMenu();
				} else {
					$(".content").addClass('content_c');
					destoryEle();
					setTimeout(function(){
						mainObjs.$wrapPage.load(baseUrl + "/itest/jsp/itestManual/itestManual.jsp");
						var notice="您没有任何权限请联系管理员,维护权限！";
						tipPermission(notice);
					},1000);
				}
			}
		);
}

//提示
function tipPermission(notice){
	$.xconfirm({
		msg:notice,
		okFn: function() {
			
		}
	});
}

//设置首页
function setSelfHomePage(){
	var url = "";
	var message = "";
	var cuId = "";
	var liNum = $("#menu li");
	var chaImg = "";
	var outlineSta = $("#outlineState").val();
//	$("#dataUrl").data("dataUrl","menu_s"+"^"+""+"^"+url);
	$.each(liNum,function(i,v){
			cuId = liNum[i].id;
			var attr = $("#"+cuId)[0].attributes[3];
			if(cuId!="menu_s"&&attr!=undefined){
				var back = attr.nodeValue;
				if(back=="background: rgb(30, 124, 251);"||back=="background: rgb(30, 124, 251) none repeat scroll 0% 0%;"){
					$("#menuId").val(cuId);
					chaImg =$("#"+cuId).find("img").attr("src");
					if(cuId=="menu_107"){
						url = mainObjs.$menu.data('menus')[cuId].url+"&taskId="+$("#taksIdmain").val()+ 
						"&analyprojectName=" + $("#analyprojectName").val() + "&analyproNum=" + $("#analyproNum").val()+"&outlineState="+outlineSta;
					}else{
						url = mainObjs.$menu.data('menus')[cuId].url+"&taskId="+$("#taksIdmain").val()+ 
						"&analyprojectName=" + $("#analyprojectName").val() + "&analyproNum=" + $("#analyproNum").val()+"&outlineState="+outlineSta;
					}
					message = "确认把"+$.trim($("#"+cuId).find('span').text())+"设置为首页吗?";
				}
			}
	});
	
	tipHomePage(message,url,$("#menuId").val(),chaImg);
}
//其他任务设置首页
function setSelfHomePage1(){
	var url = $("#"+otherId).attr("myUrl");
	var message = "确认把 " + $("#"+otherId).find("span").text() + "设置为首页吗？";
	tipHomePage1(message,url);
}

//接口菜单设置首页
function setSelfHomePageInterface(){
	var url = $("#"+interfaceId).attr("myUrl");
	var message = "确认把 " + $("#"+interfaceId).find("span").text() + "设置为首页吗？";
	tipHomePage1(message,url+"&taskId="+$("#taksIdmain").val());
}

//获取当前登录人的信息
function getCurrentLoginPer(){
	var urls = baseUrl + "/userManager/userManagerAction!setMyInfoInitLoad.action";
	$.ajax({
		  url: urls,
		  cache: false,
		  async: false,
		  type: "POST",
		  dataType:"json",
		  success: function(data){
			  if(data != null){
				  $("#loginData").data("loginData",data);
			  }else{
				  tipPermission("系统问题！");
			  }
		  }
		});
}
//提交设置其他任务首页信息
function tipHomePage1(tip,url){
	if(tip!=""){
		$.xconfirm({
			msg:tip,
			okFn: function() {
				var dataInfo = $("#loginData").data("loginData");
				var urls = baseUrl + "/userManager/userManagerAction!updateMyInfo.action?dto.isAjax=true";
				$.ajax({
					  url: urls,
					  cache: false,
					  async: false,
					  type: "POST",
					  dataType:"text",
					  data: {
						  	"dto.user.myHome":url,
						  	"dto.user.id":$("#accountId").text(),
						  	"dto.user.loginName":$("#loginName").text(),
						  	"dto.user.name":$("#userName").val(),
						  	"dto.user.email":dataInfo["dto.user"].email,
						  	"dto.user.companyId":dataInfo["dto.user"].companyId,
						  	"dto.user.delFlag":dataInfo["dto.user"].delFlag,
						  	"dto.user.insertDate":dataInfo["dto.user"].insertDate,
						  	"dto.user.isAdmin":dataInfo["dto.user"].isAdmin,
						  	"dto.user.delFlag":dataInfo["dto.user"].delFlag,
						  	"dto.user.insertDate":dataInfo["dto.user"].insertDate,
						  	"dto.user.isAdmin":dataInfo["dto.user"].isAdmin,
						  	"dto.user.status":dataInfo["dto.user"].status,
						  	"dto.user.password":dataInfo["dto.user"].password,
						  	"dto.user.oldPwd":dataInfo["dto.user"].oldPwd
						  	},
					  success: function(data){
						  if(data.indexOf("success")>=0){
							  $("#"+otherId).css('background', 'rgb(30, 124, 251) none repeat scroll 0% 0%');
							  $("#"+otherId).siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
						  }else{
							  tipPermission("系统问题！");
						  }
					  }
					});
			}
		});
	}else{
		tipNotify();
	}
	
}
//提交设置首页信息
function tipHomePage(tip,url,id,imgPath){
	var returnUrl = $("#dataUrl").data('dataUrl');
	var home_Url = "";
	var splitUrl = "";
	if(returnUrl!=undefined){
		home_Url = url;
		splitUrl = returnUrl.split("^");
	}else{
		home_Url = "/bugManager/bugManagerAction!loadAllMyBug.action?dto.allTestTask=true";
	}
	
	if(tip!=""){
		$.xconfirm({
			msg:tip,
			okFn: function() {
				var dataInfo = $("#loginData").data("loginData");
				var urls = baseUrl + "/userManager/userManagerAction!updateMyInfo.action?dto.isAjax=true";
				$.ajax({
					  url: urls,
					  cache: false,
					  async: false,
					  type: "POST",
					  dataType:"text",
					  data: {
						  	"dto.user.myHome":home_Url,
						  	"dto.user.id":$("#accountId").text(),
						  	"dto.user.loginName":$("#loginName").text(),
						  	"dto.user.name":$("#userName").val(),
						  	"dto.user.email":dataInfo["dto.user"].email,
						  	"dto.user.companyId":dataInfo["dto.user"].companyId,
						  	"dto.user.delFlag":dataInfo["dto.user"].delFlag,
						  	"dto.user.insertDate":dataInfo["dto.user"].insertDate,
						  	"dto.user.isAdmin":dataInfo["dto.user"].isAdmin,
						  	"dto.user.delFlag":dataInfo["dto.user"].delFlag,
						  	"dto.user.insertDate":dataInfo["dto.user"].insertDate,
						  	"dto.user.isAdmin":dataInfo["dto.user"].isAdmin,
						  	"dto.user.status":dataInfo["dto.user"].status
						  	},
					  success: function(data){
						  if(data.indexOf("success")>=0){
							  $("#menu_s")[0].attributes[3].nodeValue="";
							  $("#menu_s > a").find('img').attr('src',baseUrl+"/itest/images/homeImage/myHome1.png");
							  $("#menu_s > a span").css("color","#E9F6FF");
							  $("#"+id).find('img').attr('src',imgPath);
							  $("#"+id).find('span').css("color","#ffffff");
							  $("#"+id)[0].attributes[3].nodeValue="background: rgb(30, 124, 251);";
							  
							  if(splitUrl[0]!="menu_s"){
								  $("#"+splitUrl[0]).css('background','#1e7cfb');
								  $("#"+splitUrl[0]).find('img').attr('src',splitUrl[1]);
								  $("#"+splitUrl[0]).find('span').css('color','#ffffff');
							  }
						  }else{
							  tipPermission("系统问题！");
						  }
					  }
					});
			},
			cancelFn: function(){
				 $("#menu_s")[0].attributes[3].nodeValue="";
				 $("#menu_s > a").find('img').attr('src',baseUrl+"/itest/images/homeImage/myHome1.png");
				 $("#menu_s > a span").css("color","#E9F6FF");
				 $("#"+id).find('img').attr('src',imgPath);
				 $("#"+id).find('span').css("color","#ffffff");
				 $("#"+id)[0].attributes[3].nodeValue="background: rgb(30, 124, 251);";
				 
				 if(splitUrl[0]!="menu_s"&&splitUrl[0]!=undefined){
					 $("#"+splitUrl[0]).css('background','#1e7cfb');
					 $("#"+splitUrl[0]).find('img').attr('src',splitUrl[1]);
					 $("#"+splitUrl[0]).find('span').css('color','#ffffff');
				 }
			}
		});
	}else{
		tipNotify();
	}
}

function tipNotify(){
	var returnUrl = $("#dataUrl").data('dataUrl');
	$.xconfirm({
		msg:"请重新选中需要设为首页的左边菜单！",
		okFn: function() {
			
		},
		cancelFn: function(){
			
		}
		

	});
}

//首页的设置，无首页弹窗选择具体项目
function showHomePageWin(){
	getCurrentLoginPer();
	var myHome =  $("#loginData").data("loginData")["dto.user"].myHome;
	if(localStorage.taskId){
		//收到邮件跳转过来时
		 $("#taksIdmain").val(localStorage.taskId);
		 return false;
	}else{
		if(myHome!=undefined&&myHome!=""){
			if(myHome.indexOf("apiManager") != -1){
				$("#menu").hide();
			}
			$("#myhome").data("myHome",myHome);
			//将url中的参数拆分存入session
		   var proName = "",proNum="",taskId="";
		   var headerParamArr = myHome.split("&");
		   if(headerParamArr.length<=1){
			   return false;
		   }
		   var reqUrlParam = (headerParamArr.length>0)? headerParamArr.splice(0,1):headerParamArr;
		   for(var i=0;i<headerParamArr.length;i++){
			   var param = headerParamArr[i].split("=");
			       param[1] = (param[1] == null)? "":param[1];
			   switch (param[0]){
			     case "analyprojectName":{
			    	 $("#analyprojectName").val(param[1]);
	                 proName = param[1];
	                 break;
			     }
			     case "analyproNum":{
			    	 $("#analyproNum").val(param[1]); 
			    	 proNum = param[1];
			    	 break;
			     }
			     case "taskId":{
			    	 $("#taksIdmain").val(param[1]);
			    	 $("#analyitemId").val(param[1]);
			    	 taskId = param[1];
			    	 break;
			     }
			     case "outlineState":{
			    	 $("#outlineState").val(param[1]);
			    	 break;
			     }
			     
			   }  
		   }
			//将页面数据放入session
			putAnalysisSession(taskId,proName,proNum); 
			return true;
//			putTaskIdSession(taskId);
		}else{
			//切换项目弹窗
			$("#leftMenu").hide();
			$(".sidebary").hide();
			return false;
		}
	}
}

//加载新用户，没参与项目
function newUserLoadMenu(vs,is){
	var con = "";
	if(vs!=""&&vs!=undefined){
		if(vs.functionId=="68"||vs.functionId=="87"||vs.functionId=="107"||vs.functionId=="143"){
//			menus["menu_"+i] = v;
			if(vs.functionId=="68"){
				con += '<li id="menu_'+is.functionId+'" data-info="'+vs.functionId+'" class="treeview disabled">'
				+'<a href="javascript:void(0);" class="firstA">'
				+'<img class="" src="'+baseUrl+'/itest/images/homeImage/projectMan2.png">&nbsp;&nbsp;&nbsp;'
				+'<span class="" style="color: #8b94a0;">' + vs.functionName + '&nbsp;&nbsp;</span>'
				+'</a></li>';
			}else if(vs.functionId=="87"){
				con += '<li id="menu_'+is.functionId+'" data-info="'+vs.functionId+'" class="treeview disabled">'
				+'<a href="javascript:void(0);" class="firstA">'
				+'<img class="" src="'+baseUrl+'/itest/images/homeImage/testSin2.png">&nbsp;&nbsp;&nbsp;'
				+'<span class="" style="color: #8b94a0;">' + vs.functionName + '&nbsp;&nbsp;</span>'
				+'</a></li>';
			}else if(vs.functionId=="107"){
				con += '<li id="menu_'+is.functionId+'" data-info="'+vs.functionId+'" class="treeview disabled">'
				+'<a href="javascript:void(0);" class="firstA">'
				+'<img class="" src="'+baseUrl+'/itest/images/homeImage/defect2.png">&nbsp;&nbsp;&nbsp;'
				+'<span class="" style="color: #8b94a0;">' + vs.functionName + '&nbsp;&nbsp;</span>'
				+'</a></li>';
			}else if(vs.functionId=="143"){
				con += '<li id="menu_'+is.functionId+'" data-info="'+vs.functionId+'" class="treeview disabled">'
				+'<a href="javascript:void(0);" class="firstA">'
				+'<img class="" src="'+baseUrl+'/itest/images/homeImage/analysis2.png">&nbsp;&nbsp;&nbsp;'
				+'<span class="" style="color: #8b94a0;">' + vs.functionName + '&nbsp;&nbsp;</span>'
				+'</a></li>';
			}
		}
	}else{
		con = '<li id="menu_11" data-info="" class="treeview disabled">'
		+'<a href="javascript:void(0);" class="firstA">'
		+'<img class="" src="'+baseUrl+'/itest/images/homeImage/zl1.png">&nbsp;&nbsp;&nbsp;'
		+'<span class="" style="color: #8b94a0;">总览&nbsp;&nbsp;</span>'
		+'</a></li><li id="menu_11" data-info="" class="treeview disabled">'
		+'<a href="javascript:void(0);" class="firstA">'
		+'<img class="" src="'+baseUrl+'/itest/images/homeImage/projectMan2.png">&nbsp;&nbsp;&nbsp;'
		+'<span class="" style="color: #8b94a0;">测试需求管理&nbsp;&nbsp;</span>'
		+'</a></li><li id="menu_12" data-info="" class="treeview disabled">'
		+'<a href="javascript:void(0);" class="firstA">'
		+'<img class="" src="'+baseUrl+'/itest/images/homeImage/testSin2.png">&nbsp;&nbsp;&nbsp;'
		+'<span class="" style="color: #8b94a0;">测试用例管理&nbsp;&nbsp;</span>'
		+'</a></li><li id="menu_13" data-info="" class="treeview disabled">'
		+'<a href="javascript:void(0);" class="firstA">'
		+'<img class="" src="'+baseUrl+'/itest/images/homeImage/defect2.png">&nbsp;&nbsp;&nbsp;'
		+'<span class="" style="color: #8b94a0;">缺陷管理&nbsp;&nbsp;</span></a>'
		+'</li><li id="menu_14" data-info="" class="treeview disabled">'
		+'<a href="javascript:void(0);" class="firstA">'
		+'<img class="" src="'+baseUrl+'/itest/images/homeImage/analysis2.png">&nbsp;&nbsp;&nbsp;'
		+'<span class="" style="color: #8b94a0;">分析度量&nbsp;&nbsp;</span></a></li><li id="menu_14" data-info="" class="treeview disabled">'
		+'<a href="javascript:void(0);" class="firstA">'
		+'<img class="" src="'+baseUrl+'/itest/images/homeImage/testcasepkg1.png">&nbsp;&nbsp;&nbsp;'
		+'<span class="" style="color: #8b94a0;">用例包管理&nbsp;&nbsp;</span></a></li><li id="menu_14" data-info="" class="treeview disabled">'
		+'<a href="javascript:void(0);" class="firstA">'
		+'<img class="" src="'+baseUrl+'/itest/images/homeImage/myHome1.png">&nbsp;&nbsp;&nbsp;'
		+'<span class="" style="color: #8b94a0;">设置首页&nbsp;&nbsp;</span></a></li>';
	}
	return con;
}

////导航栏菜单的样式
function navMenueS(){
	var navImg = $('.navbar-left.switchm').find("img.switch");//测试
	var navImg_1= $('.navbar-left.systemM').find("img.switch");//系统设置
	var navImg_2= $('.navbar-left.elseTask').find("img.switch"); //任务
	var navImg_3= $('.navbar-left.iterations').find("img.switch"); //迭代
	var navImg_4 = $('.navbar-left.projectTo').find("img.switch");//项目
	var navImg_5 = $('.navbar-left.situation').find("img.switch");//环境
	var navImg_6 = $('.navbar-left.interface1').find("img.switch");//接口
	var switchBtn = baseUrl + '/itest/images/homeImage/switch.png';
	var swRealPath = baseUrl + '/itest/images/homeImage/switch1.png';
	
	var switchBtn_1 = navImg_1.attr('src');
	var swSplit_1 = switchBtn_1.split('.png');
	var swRealPath_1 =  swSplit_1[0]+"1.png";
	
	var switchBtn_2 = navImg_2.attr('src');
	var swSplit_2 = switchBtn_2.split('.png');
	var swRealPath_2 =  swSplit_2[0]+"1.png";
	
	var switchBtn_3 = navImg_3.attr('src');
	var swSplit_3 = switchBtn_3.split('.png');
	var swRealPath_3 =  swSplit_3[0]+"1.png";
	
	var switchBtn_4 = navImg_4.attr('src');
	var swSplit_4 = switchBtn_4.split('.png');
	var swRealPath_4 =  swSplit_4[0]+"1.png";
	
	var switchBtn_5 = navImg_5.attr('src');
	var swSplit_5 = switchBtn_5.split('.png');
	var swRealPath_5 =  swSplit_5[0]+"1.png";
	
	var switchBtn_6 = navImg_6.attr('src');
	var swSplit_6 = switchBtn_6.split('.png');
	var swRealPath_6 =  swSplit_6[0]+"1.png";
	
	//项目
	$('.navbar-left.projectTo').hover(function(){
		navImg_4.attr('src',swRealPath_4);
		$("#projectToJump").css('color','#ffffff');
		navImg_4.next().children('img.arrows').attr('src',''+baseUrl+'/itest/images/homeImage/projectTo1.png');
		navImg_4.next().children('img.arrows').css({width:'14',height:'8'});
	},function(){
		if(projectTo==0){
			navImg_4.attr('src',switchBtn_4);
			$("#projectToJump").css('color','#E9F6FF');	
		}
	});
	
	//测试
	$('.navbar-left.switchm').hover(function(){
		var path01 = $('.navbar-left.switchm').find("img.switch").attr('src');
		navImg.attr('src',swRealPath);
		$("#changePro").css('color','#ffffff');
		navImg.next().children('img.arrows').attr('src',''+baseUrl+'/itest/images/homeImage/arrow1.png');
		navImg.next().children('img.arrows').css({width:'14',height:'8'});
	},function(){
		var flag = mainObjs.$logoImg.attr("data-show"); 
		if(sysTestFlg==0){
			navImg.attr('src',switchBtn);
			$("#changePro").css('color','#E9F6FF');	
		}
		navImg.next().children('img.arrows').attr('src',''+baseUrl+'/itest/images/homeImage/arrow.png');
		navImg.next().children('img.arrows').css({width:'14',height:'8'});
	});
	
	//接口
	$('.navbar-left.interface1').hover(function(){
		var path01 = $('.navbar-left.interface1').find("img.switch").attr('src');
		navImg_6.attr('src',swRealPath_6);
		$("#interfaceL").css('color','#ffffff');
		navImg_6.next().children('img.arrows').attr('src',''+baseUrl+'/itest/images/homeImage/arrow1.png');
		navImg_6.next().children('img.arrows').css({width:'14',height:'8'});
	},function(){
		var flag = mainObjs.$logoImg.attr("data-show"); 
		if(inerfaceFlg==0){
			navImg_6.attr('src',switchBtn_6);
			$("#interfaceL").css('color','#E9F6FF');	
		}
		navImg_6.next().children('img.arrows').attr('src',''+baseUrl+'/itest/images/homeImage/arrow.png');
		navImg_6.next().children('img.arrows').css({width:'14',height:'8'});
	});
	
	//系统设置
	$('.navbar-left.systemM').hover(function(){
		navImg_1.attr('src',swRealPath_1);
		$("#systemManage").css('color','#ffffff');
		navImg_1.next().children('img.arrows').attr('src',''+baseUrl+'/itest/images/homeImage/arrow1.png');
		$(".systemMenu").show();
	},function(){
		var flag1 = mainObjs.$logoImg.attr("data-show"); 
		if(sysConfigFlg==0){
			navImg_1.attr('src',switchBtn_1);
			$("#systemManage").css('color','#E9F6FF');	
		}
		navImg_1.next().children('img.arrows').attr('src',''+baseUrl+'/itest/images/homeImage/arrow.png');
		$(".systemMenu").hide();
	});
	
	//任务
	$('.navbar-left.elseTask').hover(function(){
		navImg_2.attr('src',baseUrl+'/itest/images/homeImage/elseTs1.png');
		navImg_2.next().css('color','#ffffff');
	},function(){
		if(taskFlg==0||$("#otherMissionLeftMenu").css("display") == "none" || $("#leftMenu").css("display") == "none"){
			navImg_2.attr('src',baseUrl+'/itest/images/homeImage/elseTs.png');
			navImg_2.next().css('color','#E9F6FF');
		}
	});
	
	$(".otherMissionCl").hover(function(){
		if($(this).attr("id") == "m6"){
			$(this).css("background", "rgb(30, 124, 251) none repeat scroll 0% 0%");
		}else{
			$(this).css("background", "rgb(30, 124, 251) none repeat scroll 0% 0%");
			if($(this).attr("id") != otherId){
				$(this).children().children().attr("src",$(this).children().children().attr("src").split("1")[0]+".png");
			}
		}
	},function(){
		if($(this).attr("id") == "m6"){
			$(this).css("background", "rgb(61, 67, 81) none repeat scroll 0% 0%");
		}else{
			$(this).css("background", "rgb(61, 67, 81) none repeat scroll 0% 0%");
			if($(this).attr("id") != otherId){
				$(this).children().children().attr("src",$(this).children().children().attr("src").split(".png")[0]+"1.png");
			}
		}
		$("#"+otherId).css("background", "rgb(30, 124, 251) none repeat scroll 0% 0%");
	});
	
	$(".yongli").hover(function(){
		$(this).css("background", "rgb(30, 124, 251) none repeat scroll 0% 0%");
		if($(this).attr("id") != casId){
			$(this).children().children().attr("src",$(this).children().children().attr("src").split("1")[0]+".png");
		}
	},function(){
		$(this).css("background", "rgb(61, 67, 81) none repeat scroll 0% 0%");
		if($(this).attr("id") != casId){
			$(this).children().children().attr("src",$(this).children().children().attr("src").split(".png")[0]+"1.png");
		}
		$("#"+casId).css("background", "rgb(30, 124, 251) none repeat scroll 0% 0%");
	});
	
	$(".interfaceLi").hover(function(){
		$(this).css("background", "rgb(30, 124, 251) none repeat scroll 0% 0%");
		if($(this).attr("id") != interfaceId && $(this).children().children().attr("src").split("1").length > 1){
			$(this).children().children().attr("src",$(this).children().children().attr("src").split("1")[0]+".png");
		}
	},function(){
		$(this).css("background", "rgb(61, 67, 81) none repeat scroll 0% 0%");
		if($(this).attr("id") != interfaceId){
			$(this).children().children().attr("src",$(this).children().children().attr("src").split(".png")[0]+"1.png");
		}
		$("#"+interfaceId).css("background", "rgb(30, 124, 251) none repeat scroll 0% 0%");
	});
	
	
	//个人信息
	$('.pull-right.systemC').hover(function(){
		$("#arrowDown").attr('src',''+baseUrl+'/itest/images/homeImage/arrow1.png');
		$("#arrowDown").css('color','#ffffff');
		$("#userInfoMenus").css('display','block');
	},function(){
		$("#arrowDown").attr('src',''+baseUrl+'/itest/images/homeImage/arrow.png');
		$("#arrowDown").prev().css('color','#E9F6FF'); 
		$("#userInfoMenus").css('display','none');
	}); 
	//新增--1203
	$('.navbar-left.new_icon').hover(function(){
		$("#new_icon").attr('src',''+baseUrl+'/itest/images/Group2.png'); 
		$("#new_icon_info").css('display','block');
	},function(){
		$("#new_icon").attr('src',''+baseUrl+'/itest/images/Group.png'); 
		$("#new_icon_info").css('display','none');
	});
	//项目迭代
	$('.navbar-left.iterations').hover(function(){
		navImg_3.attr('src',swRealPath_3);
		$("#iterL").css('color','#ffffff');
		navImg_3.next().children('img.arrows').attr('src',''+baseUrl+'/itest/images/homeImage/iterList1.png');
	},function(){
		var flag = mainObjs.$logoImg.attr("data-show");
		if(sysDieFlg==0){
			navImg_3.attr('src',switchBtn_3);
			$("#iterL").css('color','#E9F6FF');
		}
	});
	
	
	//环境
	$('.navbar-left.situation').hover(function(){
			navImg_5.attr('src',swRealPath_5);
			$("#situationL").css('color','#ffffff');
			navImg_5.next().children('img.arrows').attr('src',''+baseUrl+'/itest/images/homeImage/env1.png');
		},function(){
			var flag = mainObjs.$logoImg.attr("data-show");
			if(env == 0){
				navImg_5.attr('src',switchBtn_5);
				$("#situationL").css('color','#E9F6FF');
			}
			
	});
	
}

//收缩按钮的移动样式
function sidebaryHover(){
	var btn = mainObjs.$logoImg.attr('src');
	var btnSplit = btn.split('.png');
	var realPath =  btnSplit[0]+"1.png";
	mainObjs.$logoImg.hover(function(){
		mainObjs.$logoImg.attr('src',realPath);
	},function(){
		mainObjs.$logoImg.attr('src',btn);
	});
}

//点击收缩左边菜单
mainObjs.$logoImg.click(function(){
	var showVal = mainObjs.$logoImg.attr("data-show");
	var navFlg = $("#navTop").data('effect');//标志位，判断来自nav的点击事件，去除左边菜单点亮，并不进入默认的首页
	//获取点亮左边菜单的url
	var returnVal = getLeftMenuUrl();
	var myHomes =  $("#loginData").data("loginData")["dto.user"].myHome;
	
	if(showVal=="2"){
		$("#main_header > a").width(180);
		$(".l-menu").width(180);
		$("#menu a").width(180);
		$("#menu li span").show();
		$(".aaaa").show();
		$(".main-header .sidebar-toggle").css('paddingLeft','9em');
		$(".logo .logo-lg").show();
		$(".logo .logo-min").hide();
		$(".content").removeClass('content_L').addClass('content');
		setTimeout(function(){ 
			if(returnVal!=true){
				mainObjs.$wrapPage.load(baseUrl + myHomes.split("&")[0]);
			}else{
				mainObjs.$wrapPage.load(baseUrl + $("#menuUrl").data("menuUrl"));
			}
		},100);
		mainObjs.$logoImg.attr("data-show","1");
	}else if(showVal=="1"){
		$("#menu li span").hide();
		$(".aaaa").hide();
		$("#main_header > a").width(75);
		$(".l-menu").width(75);
		$("#menu a").width(75);
		$(".main-header .sidebar-toggle").css('paddingLeft','4em');
		$(".logo .logo-lg").hide();
		$(".logo .logo-min").show();
		$(".content").addClass('content_L');
		setTimeout(function(){ 
			if(returnVal!=true){
				mainObjs.$wrapPage.load(baseUrl + myHomes.split("&")[0]);
			}else{
				mainObjs.$wrapPage.load(baseUrl + $("#menuUrl").data("menuUrl"));
			}
		},100);
		mainObjs.$logoImg.attr("data-show","2");
	}else if(showVal=="5"){
		$("#otherMissionLeftMenu li span").hide();
		$(".aaaa").hide();
		$("#main_header > a").width(75);
		$(".l-menu").width(75);
		$("#otherMissionLeftMenu a").width(75);
		$(".main-header .sidebar-toggle").css('paddingLeft','4em');
		$(".logo .logo-lg").hide();
		$(".logo .logo-min").show();
		$(".content").addClass('content_L');
		mainObjs.$logoImg.attr("data-show","6");
		mainObjs.$wrapPage.load(baseUrl + $("#"+otherId).attr("myUrl"));
	}else if(showVal=="6"){
		$("#otherMissionLeftMenu li span").show();
		$(".aaaa").show();
		$("#main_header > a").width(180);
		$(".l-menu").width(180);
		$("#otherMissionLeftMenu a").width(180);
		$(".main-header .sidebar-toggle").css('paddingLeft','9em');
		$(".logo .logo-lg").show();
		$(".logo .logo-min").hide();
		$(".content").removeClass('content_L').addClass('content');
		mainObjs.$logoImg.attr("data-show","5");
		mainObjs.$wrapPage.load(baseUrl + $("#"+otherId).attr("myUrl"));
	}else if(showVal=="7"){
		$("#caseTypeMenu li span").hide();
		$(".aaaa").hide();
		$("#main_header > a").width(75);
		$(".l-menu").width(75);
		$("#caseTypeMenu a").width(75);
		$(".main-header .sidebar-toggle").css('paddingLeft','4em');
		$(".logo .logo-lg").hide();
		$(".logo .logo-min").show();
		$(".content").addClass('content_L');
		mainObjs.$logoImg.attr("data-show","8");
		mainObjs.$wrapPage.load(baseUrl + $("#"+casId).attr("myUrl"));
	}else if(showVal=="8"){
		$("#caseTypeMenu li span").show();
		$(".aaaa").show();
		$("#main_header > a").width(180);
		$(".l-menu").width(180);
		$("#caseTypeMenu a").width(180);
		$(".main-header .sidebar-toggle").css('paddingLeft','9em');
		$(".logo .logo-lg").show();
		$(".logo .logo-min").hide();
		$(".content").removeClass('content_L').addClass('content');
		mainObjs.$logoImg.attr("data-show","7");
		mainObjs.$wrapPage.load(baseUrl + $("#"+casId).attr("myUrl"));
	}else{
		$("#leftMenu").show();
		$("#menu").show();
		$("#otherMissionLeftMenu").hide();
		$(".content").removeClass('content_c').addClass('content');
		mainObjs.$logoImg.attr("data-show","1");
	}

	if(navFlg!="noEf"&&navFlg!=undefined){
		if(returnVal!=true){
			mainObjs.$wrapPage.load(baseUrl + myHomes.split("&")[0]);
		}else{
			mainObjs.$wrapPage.load(baseUrl + $("#menuUrl").data("menuUrl"));
		}
	}else{

		
	}
	
});
//获取点亮左边菜单的url
function getLeftMenuUrl(){
	var allLi = mainObjs.$menu.find('li');
	$.each(allLi,function(i,n){
		var currPic = $("#"+allLi[i].id).find('a > img').attr('src');
		var picPath = currPic.split(".png");
		var getImg = picPath[0].split("\/");
		var lastImgName = getImg[getImg.length-1];
		if($("#"+allLi[i].id).attr('style')!=undefined){
			if(($("#"+allLi[i].id).attr('style').indexOf('background: rgb(30, 124, 251)')>=0
					||$("#"+allLi[i].id).attr('style').indexOf('background: rgb(30, 124, 251) none repeat scroll 0% 0%;')>=0)
					&&allLi[i].id!="menu_s"){
				if(lastImgName=="defect"){
					$("#menuUrl").data("menuUrl","/bugManager/bugManagerAction!loadAllMyBug.action");
				}else if(lastImgName=="projectMan"){
					$("#menuUrl").data("menuUrl","/outLineManager/outLineAction!index.action");
				}else if(lastImgName=="testSin"){
					$("#menuUrl").data("menuUrl","/caseManager/caseManagerAction!loadCase.action");
				}else if(lastImgName == "testcasepkg"){
					$("#menuUrl").data("menuUrl","/testCasePkgManager/testCasePackageAction!goTestCasePkgMain.action");
				}else if(lastImgName == "zl"){
					$("#menuUrl").data("menuUrl","/overview/overviewAction!loadInformation.action");
				}else{
					$("#menuUrl").data("menuUrl","/analysis/analysisAction!goAnalysisMain.action");
				}
				$("#homePageFlg").val("yes");
			}
		}
	});
	if($("#homePageFlg").val()!="yes"){
		return false;
	}else{
		return true;
	}
}


//移动效果
function hoverEvent(){
	mainObjs.$menu.find('li').hover(
	  function () {
			var aPos =  $(this).children().filter('a[class!="childA"]');
			imgPath = aPos["0"].children["0"].attributes[1].nodeValue;
			picName = imgPath.split("/");
			var pngsp = imgPath.split("1.png");
			if(imgPath.indexOf("1")>=0){
				hover = pngsp[0]+".png";
				$("#adds").data('sty',0);	
			}else{
				hover = pngsp[0];
				$("#adds").data('sty',1);
			}
			$(this).css('background','#1E7CFB');
			aPos.find('img[src$="'+picName[5]+'"]').attr('src',hover);
			if(aPos["0"].children[2]!=undefined){
				aPos["0"].children[2].attributes[1].nodeValue=baseUrl+"/itest/images/homeImage/"+"upArr2.png";
			}
			aPos.find('span').css('color','#ffffff');
	  },
	  function () {
		 if($("#adds").data('sty')!=1){
			 var outLi = $(this).children().filter('a[class!="childA"]');
			 $(this).css('background','#3d4351');
			 outLi["0"].children["0"].attributes[1].nodeValue = imgPath;
			 if(outLi["0"].children[2]!=undefined){
				outLi["0"].children[2].attributes[1].nodeValue=baseUrl+"/itest/images/homeImage/"+"upArr1.png";
			 }
			 outLi.find('span').css('color','#E9F6FF');
			 $("#adds").data('sty',0);
		 }
	  }
	);
}
function init() {
	var pFlag = $("#projectFlag").val();
	if(pFlag!="1"){
		$("#wrap-page").css('padding','0px');
		$("#noPro").show();
	}else{
		if(localStorage.taskId){
			//点击邮件链接过来时
			$.post(baseUrl + "/singleTestTask/singleTestTaskAction!updInit.action",{
				"dto.singleTest.taskId":localStorage.taskId
			},function(data){
				$('#changePro').html("");
				$("#changePro").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/switch1.png');
				sysTestFlg=1;
				if(data["dto.singleTest"].proName.length > 3){
					$('#changePro').html("测试 > "+data["dto.singleTest"].proName.substring(0,2)+"...");
				}else{
					$('#changePro').html("测试 > "+data["dto.singleTest"].proName);
				}
				$('#changePro').attr("title",data["dto.singleTest"].proName);
				$("#outlineState").val("1");
			},'json');
			//缺陷管理
			$("#menu_107").attr('style','background: rgb(30, 124, 251);');
			$("#menu_107").find('img').removeAttr('src');
			$("#menu_107").find('img').attr('src',baseUrl+"/itest/images/homeImage/defect.png");
			$("#menu_107").find('span').css('color','#ffffff');
			mainObjs.$wrapPage.load(baseUrl + '/bugManager/bugManagerAction!loadAllMyBug.action');
		}else{
			var homeUrl =$("#myhome").data("myHome");
			if(homeUrl!=""&&homeUrl!=undefined){
				//是否与项目有关，有关的话，查出项名名称
				if(homeUrl.indexOf("taskId") != -1){
					var taId = homeUrl.split("taskId=")[1].split("&")[0];
					$.post(baseUrl + "/singleTestTask/singleTestTaskAction!updInit.action",{
						"dto.singleTest.taskId":taId
					},function(data){
						if(homeUrl.indexOf("apiManager") != -1){
							$('#interfaceL').html("");
							$("#interfaceImg").attr("src",baseUrl + '/itest/images/homeImage/interface.png');
//							sysInterfaceFlg=1;
							if(data["dto.singleTest"].proName.length > 3){
								$('#interfaceL').html("接口 > "+data["dto.singleTest"].proName.substring(0,2)+"...");
							}else{
								$('#interfaceL').html("接口 > "+data["dto.singleTest"].proName);
							}
							$('#interfaceL').attr("title",data["dto.singleTest"].proName);
//							$("#interfaceL").css("color","#ffffff");
						}else{
							$('#changePro').html("");
							$("#changePro").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/switch1.png');
							sysTestFlg=1;
							if(data["dto.singleTest"].proName.length > 3){
								$('#changePro').html("测试 > "+data["dto.singleTest"].proName.substring(0,2)+"...");
							}else{
								$('#changePro').html("测试 > "+data["dto.singleTest"].proName);
							}
							$('#changePro').attr("title",data["dto.singleTest"].proName);
						}
						$("#outlineState").val(data["dto.singleTest"].outlineState);
					},'json');
				}
				if(homeUrl.indexOf("otherMission") != -1){
					//跳转到设置的其他任务
					//otherMissionFirstPage(homeUrl);
						setTimeout(function(){
						otherMissionFirstPage(homeUrl);
					},200);
				}else if(homeUrl.indexOf("apiManager") != -1){
					setTimeout(function(){
						apiManagerFirstPage(homeUrl);
					},200);
				}else{
					if(homeUrl.indexOf("loadAllMyBug.action")>=0){
						//缺陷管理
						$("#menu_107").attr('style','background: rgb(30, 124, 251);');
						$("#menu_107").find('img').removeAttr('src');
						$("#menu_107").find('img').attr('src',baseUrl+"/itest/images/homeImage/defect.png");
						$("#menu_107").find('span').css('color','#ffffff');
					}else if(homeUrl.indexOf("goAnalysisMain.action")>=0){
						//分析度量
						$("#menu_143").attr('style','background: rgb(30, 124, 251);');
						$("#menu_143").find('img').removeAttr('src');
						$("#menu_143").find('img').attr('src',baseUrl+"/itest/images/homeImage/analysis.png");
						$("#menu_143").find('span').css('color','#ffffff');
					}else if(homeUrl.indexOf("loadCase.action")>=0){
						//测试用例管理
						$("#menu_87").attr('style','background: rgb(30, 124, 251);');
						$("#menu_87").find('img').removeAttr('src');
						$("#menu_87").find('img').attr('src',baseUrl+"/itest/images/homeImage/testSin.png");
						$("#menu_87").find('span').css('color','#ffffff');
					}else if(homeUrl.indexOf("index.action")>=0){
						//测试需求管理
						$("#menu_68").attr('style','background: rgb(30, 124, 251);');
						$("#menu_68").find('img').removeAttr('src');
						$("#menu_68").find('img').attr('src',baseUrl+"/itest/images/homeImage/projectMan.png");
						$("#menu_68").find('span').css('color','#ffffff');
					}else if(homeUrl.indexOf("overviewAction")>=0){
						//总览
						$("#menu_13").attr('style','background: rgb(30, 124, 251);');
						$("#menu_13").find('img').removeAttr('src');
						$("#menu_13").find('img').attr('src',baseUrl+"/itest/images/homeImage/zl.png");
						$("#menu_13").find('span').css('color','#ffffff');
					}else /*if(homeUrl.indexOf("goTestCasePkgMain.action")>=0)*/{
						//缺陷管理
						$("#menu_11").attr('style','background: rgb(30, 124, 251);');
						$("#menu_11").find('img').removeAttr('src');
						$("#menu_11").find('img').attr('src',baseUrl+"/itest/images/homeImage/testcasepkg.png");
						$("#menu_11").find('span').css('color','#ffffff');
					}
					setTimeout(function(){
						mainObjs.$wrapPage.load(baseUrl + homeUrl.split("&")[0]);
					},100);
				}
			}else{
				$(".content").addClass('content_c');
				destoryEle();
				setTimeout(function(){
					mainObjs.$wrapPage.load(baseUrl + "/itest/jsp/itestManual/itestManual.jsp");
				},100);
			}
		}
	}
	
	mainObjs.$menu.on('click', 'li', function(e) {
		var id = this.id;
		var functionId = $(this).attr('data-info');
		var url = mainObjs.$menu.data('menus')[id] ? mainObjs.$menu.data('menus')[id].url : null;
		$("#dataUrl").data("dataUrl",id+"^"+$("#"+id).find('img').attr('src')+"^"+url);
		
		if($("#outlineState").val()!="1"){//未提交测试需求
			if(id=="menu_107"||id=="menu_87"||id=="menu_143"||id=="menu_11"){
				var homepa_s = "";
				var clickData = $("#dataUrl").data("dataUrl").split("^");
				if($("#myhome").data("myHome")!=undefined){
					homepa_s = $("#myhome").data("myHome").split("&");
					if(homepa_s[0]==clickData[2]){
						$("#"+clickData[0]).css('background',' rgb(30, 124, 251);');
						$("#"+clickData[0]).find('img').attr('src',hover);
						$("#"+clickData[0]).find('span').css('color','#ffffff');
					}
					$.xalert({title:'提示',msg:'因测试需求没提交，请提交测试需求!'});
					return;
				}else{
					$.xalert({title:'提示',msg:'因测试需求没提交，请提交测试需求!'});
					return;
				}
			}
		}
		
			$("#"+id).css('background',' rgb(30, 124, 251);');
			$("#"+id).find('img').attr('src',hover);
			$("#"+id).find('span').css('color','#ffffff');
			$("#adds").data('sty',0);
			if(id=="menu_s"){
				setSelfHomePage();
			}
			
			var allLi = mainObjs.$menu.find('li');
			$.each(allLi,function(i,n){
				var firstD ="";
				var currPic = $("#"+allLi[i].id).find('a > img').attr('src');
				var picPath = currPic.split(".png");
				if($("#"+allLi[i].id).attr('style')!=undefined){
					firstD = $("#"+allLi[i].id).attr('style').indexOf('background: rgb(30, 124, 251)');
					if(firstD>=0){
						if(id!=allLi[i].id){
							$("#"+allLi[i].id).attr('style','');
							$("#"+allLi[i].id).find('img').attr('src',picPath[0]+"1.png");
							$("#"+allLi[i].id).find('span').css('color','#E9F6FF');
						}
					$("#adds").data('sty',1);
					}
				}
				
			});		
			
		if(url=="/userManager/userManagerAction!setMyInfoInit.action"){
			showAddWin01();
			return;
		}
		if (url) {
			destoryEle();
			mainObjs.$wrapPage.load(baseUrl + url);
		}
	});
}

//摧毁页面残余元素
function destoryEle(){
	var destroyEle = $('body>div.window>div.window-body').not("[id='caseItemWin']").not('div[id="addOrEditWinUserInfo"]').not('div[id="ldapConfigInfoWin"]');
	$.each(destroyEle,function(i,v){
		$("#"+v.id).parent().next().remove();
		$("#"+v.id).parent().remove();
	});
}



function dgResize() {
	clearTimeout(timer);
	var timer = setTimeout(function() {
			$('.panel-body', $(".wrapper")).panel('resize');
		}, 301);
}
function showAddWin01(){
	pwdFlag01='0';
	oldPwdFlag02='0';
	mainObjs.$addOrEditForm.xform('clear');
	mainObjs.$addOrEditWin.parent().css("border","none");
	mainObjs.$addOrEditWin.prev().css({ color: "#ffff", background: "#101010" });
	loadMyInfo01();
	mainObjs.$addOrEditWin.xwindow('setTitle','修改个人信息').xwindow('open');
	var pss = document.getElementById("password");
	$(pss).next().children().change(function(){
		pwdFlag01='1';
	});
	var pss1 = document.getElementById("rePwd01");
	$(pss1).next().children().change(function() {
		if (pwdFlag01 == '1' && $("#oldPwd").xtextbox('getValue') == '4567KK6slygjk') {
			$("#oldPwd").xtextbox('setValue', '');
		}

	});
	
	var pss2 = document.getElementById("oldPwd");
	$(pss2).next().children().change(function(){
		oldPwdFlag02='1';
	});
	
}
function closeWin01(){
	mainObjs.$addOrEditWin.xwindow('close');
}
function submitUserInfo(){
	var objData = mainObjs.$addOrEditWin.xserialize(); 
	if(!objData["dto.user.loginName"]){ 
		tipPermission("请输入登陆号！");
        return;
	} 
	if(!objData["dto.user.name"]){ 
		tipPermission("请输入真实姓名！");
        return;
	}
	if(!objData["dto.user.password"]){ 
		tipPermission("请输入密码！");
        return;
	}else if(objData["dto.user.password"].length<6||objData["dto.user.password"].length>13){
		$.xalert({title:'验证失败',msg:'请输入6-13位的密码！'});
        return
	}else if(judgeAllSpace(objData["dto.user.password"])){
		$.xalert({title:'验证失败',msg:'请输入包含字母、数字和特殊符号的密码！'});
        return
	}
	if(!objData["repwd"]){ 
		tipPermission("请确认密码！");
        return;
	} 
	if (oldPwdFlag02 != 1 && pwdFlag01 == 1) {
		tipPermission("请输入原始密码！");
		return;

	}
	if(!objData["dto.user.oldPwd"]){
		tipPermission("请输入原始密码！");
		return;

	}
	if(objData["repwd"]==objData["dto.user.password"]&&objData["dto.user.password"]!=""){
		 //upd 
		if(pwdFlag01=='1'){
			objData["dto.user.chgPwdFlg"]=$("#accountId").text();
		}
		if(pwdFlag01=='0'&&oldPwdFlag02=='1'){
			objData["dto.user.chgPwdFlg"]='2';
		}
		if(pwdFlag01=='0'&&oldPwdFlag02=='0'){
			objData["dto.user.chgPwdFlg"]="";
		}
		$.post(  
				baseUrl + "/userManager/userManagerAction!updateMyInfo.action?dto.isAjax=true",
				objData,
				function(data) { 
					if(data.indexOf("success")>-1){
						tipPermission("修改个人信息成功！");
						mainObjs.$addOrEditWin.xwindow('close'); 
					}else if(data.indexOf("原密码不正确")>-1){
						tipPermission("原密码不正确！");
					}else if(data.indexOf("existed")>-1){
						tipPermission("该登陆名已存在！"); 
					}else{
						tipPermission("修改个人信息失败！");
					}
				},"text"
			);	
		
	}else{
		tipPermission("两次输入的密码不一致！！");
        return
	}
	
}
function loadMyInfo01(){
	$.getJSON(
			baseUrl + "/userManager/userManagerAction!setMyInfoInitLoad.action",
			{},       
			function(data) {
				mainObjs.$addOrEditWin.xdeserialize(data);
				$("#oldPwd").textbox("setValue", data["dto.user"].password);
				$("#rePwd01").textbox("setValue",data["dto.user"].password);
				}); 
	
}
function resetInfo01(){
	mainObjs.$addOrEditForm.xform('clear');
	$.getJSON(
			baseUrl + "/userManager/userManagerAction!setMyInfoInitLoad.action",
			{},       
			function(data) {
				mainObjs.$addOrEditWin.xdeserialize(data);
				$("#oldPwd").textbox("setValue", data["dto.user"].password);
				$("#rePwd01").textbox("setValue",data["dto.user"].password);
				}); 
}

function directJump2Task(){
	
	$(".sidebary").show();
	//切换系统管理的效果
//	systemManX();
	destoryEle();
	mainObjs.$wrapPage.empty();
	$('#changePro').html("");
	$("#changePro").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/switch1.png');
	sysTestFlg=1;
	if(onlyOneTaskName.length > 3){
		$('#changePro').html("测试 > "+onlyOneTaskName.substring(0,2)+"...");
	}else{
		$('#changePro').html("测试 > "+onlyOneTaskName);
	}
	$('#changePro').attr("title",onlyOneTaskName);	
	
	setTimeout(function(){
		//mainObjs.$wrapPage.load(baseUrl + "/overview/overviewAction!loadInformation.action?taskId="+onlyOneTaskId);
		var dataU = $("#dataUrl").data('dataUrl');
		if(dataU!=undefined&&dataU.indexOf('menu_s')<0){
			//有值,定位到用例管理, 第一个参数这里没有用，所以要传一个空过，要不不能识别dataU
			exampleManager('',dataU);
		}else{
			//无值,根据选择的项目定位到缺陷管理
			defectManager('');
		}
	},250);
	$("#menu").show();
	$("#otherMissionLeftMenu").hide();
	$("#caseTypeMenu").hide();
	$("#systemManage").css("color","#e9f6ff");
	$("#systemManage").html("设置");
	$("#systemM").css("margin","20px 0 -5px");
	$(".content").removeClass('content_c').addClass('content');
	$("#leftMenu").show();
	taskFlg = 0;
	sysTestFlg = 1;
	sysDieFlg = 0;
	inerfaceFlg = 0;
	sysConfigFlg = 0;
	projectTo=0;
	env = 0;
	$("#changeProjectName").val("");
	$("#projectToJump").html("项目");
	$("#projectToJump").css("color","#e9f6ff");
	$("#projectToJump").prev().attr("src",baseUrl + '/itest/images/homeImage/projectTo.png');
	$('#iterL').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/iterList.png');
	$("#otherMissionssss").css("color","#e9f6ff");
	$("#otherMissionImg").attr('src',baseUrl+'/itest/images/homeImage/elseTs.png');
	$("#situationL").html("环境");
	$("#situationL").css("color","#e9f6ff");
	$("#situationL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/env.png');
	//removeLeftMenuEffect();
	//跳转到其他任务时，将data-show设为22或5，用于区分左边菜单收缩效果
	if($('#leftMenu').width()=='75'){
		$('#menu li span').hide();
		mainObjs.$logoImg.attr("data-show","2");
	}else{
		mainObjs.$logoImg.attr("data-show","1");
	}
}

function directJump2ApiTask(){
	$(".sidebary").show();
	destoryEle();
	mainObjs.$wrapPage.empty();
	$('#changePro').html("");
	$("#changePro").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/switch1.png');
	sysTestFlg=1;
	$('#interfaceL').html("");
	if(onlyOneTaskName.length > 3){
		$('#interfaceL').html("接口 > "+onlyOneTaskName.substring(0,2)+"...");
	}else{
		$('#interfaceL').html("接口 > "+onlyOneTaskName);
	}
	$('#interfaceL').attr("title",onlyOneTaskName);
	$('#interfaceL').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/interface1.png');
	$('#interfaceL').css('color','#ffffff');
	$(".l-menu").show();
	$(".content").removeClass('content_c').addClass('content');
	
	setTimeout(function(){
		if(!$("#i1").is(':hidden')){
			$("#i1").css("background","rgb(30, 124, 251) none repeat scroll 0% 0%");
			if($("#i1").children().children().attr("src").split("1").length > 1){
				$("#i1").children().children().attr("src",$("#i1").children().children().attr("src").split("1")[0]+".png");
			}
			$("#i1").siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
			interfaceId = "i1";
			mainObjs.$wrapPage.load(baseUrl + "/apiManager/apiManagerAction!testSceneView.action");
		}else if(!$("#i2").is(':hidden')){
			$("#i2").css("background","rgb(30, 124, 251) none repeat scroll 0% 0%");
			if($("#i2").children().children().attr("src").split("1").length > 1){
				$("#i2").children().children().attr("src",$("#i2").children().children().attr("src").split("1")[0]+".png");
			}
			$("#i2").siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
			interfaceId = "i2";
			mainObjs.$wrapPage.load(baseUrl + "/apiManager/apiManagerAction!interfaceManage.action");
		}else if(!$("#i3").is(':hidden')){
			$("#i3").css("background","rgb(30, 124, 251) none repeat scroll 0% 0%");
			if($("#i3").children().children().attr("src").split("1").length > 1){
				$("#i3").children().children().attr("src",$("#i3").children().children().attr("src").split("1")[0]+".png");
			}
			$("#i3").siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
			interfaceId = "i3";
			mainObjs.$wrapPage.load(baseUrl + "/apiManager/apiManagerAction!testSceneManage.action");
		}else if(!$("#i4").is(':hidden')){
			$("#i4").css("background","rgb(30, 124, 251) none repeat scroll 0% 0%");
			if($("#i4").children().children().attr("src").split("1").length > 1){
				$("#i4").children().children().attr("src",$("#i4").children().children().attr("src").split("1")[0]+".png");
			}
			$("#i4").siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
			interfaceId = "i4";
			mainObjs.$wrapPage.load(baseUrl + "/apiManager/apiCrontabAction!crontabManage.action");
		}
	},250);
	$("#menu").show();
	$("#otherMissionLeftMenu").hide();
	$("#caseTypeMenu").hide();
	$("#systemManage").css("color","#e9f6ff");
	$("#systemManage").html("设置");
	$("#systemM").css("margin","20px 0 -5px");
	$(".content").removeClass('content_c').addClass('content');
	$("#leftMenu").show();
	
	taskFlg = 0;
	sysTestFlg = 0;
	inerfaceFlg = 1;
	sysDieFlg = 0;
	sysConfigFlg = 0;
	projectTo=0;
	env=0;

	$("#changeProjectName").val("");
	$("#projectToJump").html("项目");
	$("#projectToJump").css("color","#e9f6ff");
	$("#projectToJump").prev().attr("src",baseUrl + '/itest/images/homeImage/projectTo.png');
	$('#iterL').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/iterList.png');
	$("#otherMissionssss").css("color","#e9f6ff");
	$("#otherMissionImg").attr('src',baseUrl+'/itest/images/homeImage/elseTs.png');
	$("#situationL").html("环境");
	$("#situationL").css("color","#e9f6ff");
	$("#situationL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/env.png');
	$("#changePro").html("测试");
	$('#changePro').removeAttr("title");
	$("#changePro").css("color","#e9f6ff");
	$("#changePro").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/switch.png');
	var dataU = $("#dataUrl").data('dataUrl');
	$("#menu").hide();
	$("#interfaceMenu").show();
	$("#leftMenu").show();
	$(".sidebary").show();
	//跳转到其他任务时，将data-show设为22或5，用于区分左边菜单收缩效果
	if($('#leftMenu').width()=='75'){
		$('#menu li span').hide();
		mainObjs.$logoImg.attr("data-show","2");
	}else{
		mainObjs.$logoImg.attr("data-show","1");
	}

	removeLeftMenuEffect();
}
//切换项目
function caseItems(){
	var menuAuthUrl =  menus['menu_13'];
	var homeUrls = $("#loginData").data("loginData")["dto.user"].myHome;
	if(homeUrls!=undefined&&homeUrls!=""){
		var urlSplitR = homeUrls.split('&')[0];
		if(privilegeMap[urlSplitR]!="1" && homeUrls.indexOf("otherMission") == -1 && homeUrls.indexOf("apiManager") == -1){
			tipPermission('请联系管理员增加总览权限！');
			return;
		}else{
			if(haveJoinProject()){
				if(onlyOneTaskId!=""){
					directJump2Task();
					return;
				}else{
					$("#caseItemWin").xwindow('open');
				}
			}else{
				taskFlg = 0;
				sysTestFlg = 1;
				inerfaceFlg = 0;
				sysDieFlg = 0;
				sysConfigFlg = 0;
				projectTo=0;
				env = 0;
				$("#changeProjectName").val("");
				$("#projectToJump").html("项目");
				$("#projectToJump").css("color","#e9f6ff");
				$("#projectToJump").prev().attr("src",baseUrl + '/itest/images/homeImage/projectTo.png');
				
				$('#iterL').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/iterList.png');
				
				$("#otherMissionssss").css("color","#e9f6ff");
				$("#otherMissionImg").attr('src',baseUrl+'/itest/images/homeImage/elseTs.png');
				
				$("#situationL").html("环境");
				$("#situationL").css("color","#e9f6ff");
				$("#situationL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/env.png');
				
				$("#interfaceL").html("接口");
				$('#interfaceL').removeAttr("title");
				$("#interfaceL").css("color","#e9f6ff");
				$("#interfaceL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/interface.png');
				
				var imgPath = baseUrl+'/itest/images/homeImage/noProject.png';

				$("#otherMissionLeftMenu").hide();
				$("#interfaceMenu").hide();
				$('#caseTypeMenu').hide();
				$("#leftMenu").show();
				$('#menu').show();
				$('#menu').addClass("disabled");
				$("#wrap-page").find('.manualPage').remove();
				$('#wrap-page').empty();
				$("#wrap-page").append('<div id=\"noPro\" style=\"background-color:#F6F6F6;height:100%;\">'
						+'<img alt=\"\" src='+imgPath+' style=\"margin: 19% 42%;\">'
						+'<span style=\"font-size: 20px;font-weight: bold;float: right;margin: -15% 10%;\">您目前还没有参与任何项目测试，被设置到项目的测试流程中才被视为参与了该项目的测试工作</span></div>');
				mainObjs.$menu.parent().attr('style','display:block;');
				/*$("#wrap-page").css('padding','0px');*/
				$(".content").removeClass('content_c').addClass('content');

				return;
			}
		}
	}else{
		if(menuAuthUrl!=undefined){
			if(haveJoinProject()){
				if(onlyOneTaskId!=""){
					directJump2Task();
					return;
				}else{
					$("#caseItemWin").xwindow('open');
				}
			}else{
				taskFlg = 0;
				sysTestFlg = 1;
				inerfaceFlg = 0;
				sysDieFlg = 0;
				sysConfigFlg = 0;
				projectTo=0;
				env = 0;
				$("#changeProjectName").val("");
				$("#projectToJump").html("项目");
				$("#projectToJump").css("color","#e9f6ff");
				$("#projectToJump").prev().attr("src",baseUrl + '/itest/images/homeImage/projectTo.png');
				
				$('#iterL').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/iterList.png');
				
				$("#otherMissionssss").css("color","#e9f6ff");
				$("#otherMissionImg").attr('src',baseUrl+'/itest/images/homeImage/elseTs.png');
				
				$("#interfaceL").html("接口");
				$('#interfaceL').removeAttr("title");
				$("#interfaceL").css("color","#e9f6ff");
				$("#interfaceL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/interface.png');
				
				$("#situationL").html("环境");
				$("#situationL").css("color","#e9f6ff");
				$("#situationL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/env.png');
				
				var imgPath = baseUrl+'/itest/images/homeImage/noProject.png';
				$("#otherMissionLeftMenu").hide();
				$("#interfaceMenu").hide();
				$('#caseTypeMenu').hide();
				$("#leftMenu").show();
				$('#menu').show();
				$('#menu').addClass("disabled");
				$("#wrap-page").find('.manualPage').remove();
				$('#wrap-page').empty();
				$("#wrap-page").append('<div id=\"noPro\" style=\"background-color:#F6F6F6;height:100%;\">'
						+'<img alt=\"\" src='+imgPath+' style=\"margin: 19% 42%;\">'
						+'<span style=\"font-size: 20px;font-weight: bold;float: right;margin: -15% 10%;\">您目前还没有参与任何项目测试，被设置到项目的测试流程中才被视为参与了该项目的测试工作</span></div>');
				mainObjs.$menu.parent().attr('style','display:block;');
				/*$("#wrap-page").css('padding','0px');*/
				$(".content").removeClass('content_c').addClass('content');

				return;
			}
		}else{
			tipPermission('请联系管理员增加总览权限！');
			return;
		}
	}
	var urls = baseUrl + '/singleTestTask/singleTestTaskAction!swTestTaskList.action?dto.operCmd=caseList';
	setTimeout(function(){//caseItemList 放在timeOut 解决，有时候列表没撑开的BUG
		$("#caseItemList").xdatagrid({
			url:urls,
			method: 'get',
			height: mainObjs.tableHeight,
			fitColumns:true,
			striped:false,
			singleSelect:true,
			checkOnSelect:true,
			scrollbarSize:100,
			queryParams:{},
			pagination: true,
			emptyMsg:"暂无数据",
			pageNumber: 1,
			pageSize: 15,
			pageList: [15,30,50,100],
			layout:['list','first','prev','manual', "sep",'next','last','refresh','info'],
			rowStyler: function(index,row){
				if (row.status=='0'){
				}
			},
			onLoadSuccess:function(data){
				if(data.total>0){
					if($("#projectFlag").val()=="0"){
						$("#projectFlag").val("1");
						$("#menu").empty();
						loadLeftMenus();
					}
					$("#caseItemWin").window("vcenter");
				}else{
					if(enterKey!="noData"){
						var imgPath = baseUrl+'/itest/images/homeImage/noProject.png';
						$("#otherMissionLeftMenu").hide();
						$('#caseTypeMenu').hide();
						$("#leftMenu").show();
						$('#menu').show();
						$('#menu').addClass("disabled");
						$("#wrap-page").find('.manualPage').remove();
						$('#wrap-page').empty();
						$("#wrap-page").append('<div id=\"noPro\" style=\"background-color:#F6F6F6;height:100%;\">'
								+'<img alt=\"\" src='+imgPath+' style=\"margin: 19% 42%;\">'
								+'<span style=\"font-size: 20px;font-weight: bold;float: right;margin: -15% 10%;\">您目前还没有参与任何项目测试，被设置到项目的测试流程中才被视为参与了该项目的测试工作</span></div>');
						mainObjs.$menu.parent().attr('style','display:block;');
						$(".content").removeClass('content_c').addClass('content');
					}
				}
				$("#caseItemList").xdatagrid('resize');
			},
			onClickRow:function(rowIndex, rowData){
				taskFlg = 0;
				sysTestFlg = 1;
				inerfaceFlg = 0;
				sysDieFlg = 0;
				sysConfigFlg = 0;
				projectTo=0;
				env=0;
				$("#changeProjectName").val("");
				$("#projectToJump").html("项目");
				$("#projectToJump").css("color","#e9f6ff");
				$("#projectToJump").prev().attr("src",baseUrl + '/itest/images/homeImage/projectTo.png');
				$('#iterL').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/iterList.png');
				$("#otherMissionssss").css("color","#e9f6ff");
				$("#otherMissionImg").attr('src',baseUrl+'/itest/images/homeImage/elseTs.png');
				$("#situationL").html("环境");
				$("#situationL").css("color","#e9f6ff");
				$("#situationL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/env.png');
				
				$("#interfaceL").html("接口");
				$('#interfaceL').removeAttr("title");
				$("#interfaceL").css("color","#e9f6ff");
				$("#interfaceL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/interface.png');
				var dataU = $("#dataUrl").data('dataUrl');
				$("#leftMenu").show();
				$(".sidebary").show();
				$("#taksIdmain").val(rowData.taskId);
				$("#outlineState").val(rowData.outlineState);	
				//分析度量
				//将分析度量页面数据放入session
				$("#analyitemId").val(rowData.taskId); 
				$("#analyprojectName").val(rowData.proName); 
				$("#analyproNum").val(rowData.proNum); 
				putAnalysisSession(rowData.taskId,rowData.proName,rowData.proNum);
				$("#addMenus").css('marginLeft','5em');
				if($('#leftMenu').width()=='75'){
					$('#menu li span').hide();
					mainObjs.$logoImg.attr("data-show","2");
				}else{
					mainObjs.$logoImg.attr("data-show","1");
				}
				$('#changePro').html("");
				if(rowData.proName.length > 3){
					$('#changePro').html("测试 > "+rowData.proName.substring(0,2)+"...");
				}else{
					$('#changePro').html("测试 > "+rowData.proName);
				}
				$('#changePro').attr("title",rowData.proName);
				$('#changePro').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/switch1.png');
				$('#changePro').css('color','#ffffff');
				$(".l-menu").show();
				$(".content").removeClass('content_c').addClass('content');
				
				$("#menu").show();
				$("#otherMissionLeftMenu").hide();
				$("#caseTypeMenu").hide();
				$("#interfaceMenu").hide();
				$("#systemManage").css("color","#e9f6ff");
				$("#systemManage").html("设置");
				$("#systemM").css("margin","20px 0 -5px");
				
				removeLeftMenuEffect();
				//切换系统管理的效果
				systemManX();
				if(dataU!=undefined&&dataU.indexOf('menu_s')<0){
					//有值,定位到用例管理
					exampleManager(rowData,dataU);
				}else{
					//无值,根据选择的项目定位到缺陷管理
					defectManager(rowData);
				}
				
				//每15分钟更新下session
				updateSession();
			},
			columns:[[
				{field:'proNum',title:'项目编号',width:'20%',align:'left',halign:'center'},
				{field:'proName',title:'项目名称',width:'30%',align:'left',halign:'center'},
				{field:'psmName',title:'项目PM',width:'25%',align:'left',halign:'center'},
				{field:'status',title:'状态',width:'10%',align:'left',halign:'center',formatter:statusFormats},
				{field:'testLdVos',title:'测试负责人',width:'28.4%',align:'left',halign:'center',formatter:testerFormat}
			]],
		});
	
	},250);
}

//接口切换项目
function caseItems1(){
	if(haveJoinProject()){
		if(onlyOneTaskId!=""){
			directJump2ApiTask();
			return;
		}else{
			$("#caseItemWin").xwindow('open');
		}
	}else{
		taskFlg = 0;
		sysTestFlg = 0;
		inerfaceFlg = 1;
		sysDieFlg = 0;
		sysConfigFlg = 0;
		projectTo=0;
		env = 0;
		$("#changeProjectName").val("");
		$("#projectToJump").html("项目");
		$("#projectToJump").css("color","#e9f6ff");
		$("#projectToJump").prev().attr("src",baseUrl + '/itest/images/homeImage/projectTo.png');
		
		$('#iterL').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/iterList.png');
		
		$("#otherMissionssss").css("color","#e9f6ff");
		$("#otherMissionImg").attr('src',baseUrl+'/itest/images/homeImage/elseTs.png');
		
		$("#situationL").html("环境");
		$("#situationL").css("color","#e9f6ff");
		$("#situationL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/env.png');
		
		$("#changePro").html("测试");
		$('#changePro').removeAttr("title");
		$("#changePro").css("color","#e9f6ff");
		$("#changePro").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/switch.png');
		
		var imgPath = baseUrl+'/itest/images/homeImage/noProject.png';

		$("#otherMissionLeftMenu").hide();
		$('#caseTypeMenu').hide();
		$("#interfaceMenu").show();
		$("#leftMenu").hide();
		$('#menu').show();
		$('#menu').addClass("disabled");
		$("#wrap-page").find('.manualPage').remove();
		$('#wrap-page').empty();
		$("#wrap-page").append('<div id=\"noPro\" style=\"background-color:#F6F6F6;height:100%;\">'
				+'<img alt=\"\" src='+imgPath+' style=\"margin: 19% 42%;\">'
				+'<span style=\"font-size: 20px;font-weight: bold;float: right;margin: -15% 10%;\">您目前还没有参与任何项目测试，被设置到项目的测试流程中才被视为参与了该项目的测试工作</span></div>');
		mainObjs.$menu.parent().attr('style','display:block;');
		$(".content").removeClass('content_c').addClass('content');

		return;
	}
	
	var urls = baseUrl + '/singleTestTask/singleTestTaskAction!swTestTaskList.action?dto.operCmd=caseList';
	setTimeout(function(){//caseItemList 放在timeOut 解决，有时候列表没撑开的BUG
		$("#caseItemList").xdatagrid({
			url:urls,
			method: 'get',
			height: mainObjs.tableHeight,
			fitColumns:true,
			striped:false,
			singleSelect:true,
			checkOnSelect:true,
			scrollbarSize:100,
			queryParams:{},
			pagination: true,
			emptyMsg:"暂无数据",
			pageNumber: 1,
			pageSize: 15,
			pageList: [15,30,50,100],
			layout:['list','first','prev','manual', "sep",'next','last','refresh','info'],
			rowStyler: function(index,row){
				if (row.status=='0'){
				}
			},
			onLoadSuccess:function(data){
				if(data.total>0){
					if($("#projectFlag").val()=="0"){
						$("#projectFlag").val("1");
						$("#menu").empty();
						loadLeftMenus();
					}
					$("#caseItemWin").window("vcenter");
				}else{
					if(enterKey!="noData"){
						var imgPath = baseUrl+'/itest/images/homeImage/noProject.png';
						$("#otherMissionLeftMenu").hide();
						$('#caseTypeMenu').hide();
						$("#leftMenu").show();
						$('#menu').show();
						$("#interfaceMenu").hide();
						$('#menu').addClass("disabled");
						$("#wrap-page").find('.manualPage').remove();
						$('#wrap-page').empty();
						$("#wrap-page").append('<div id=\"noPro\" style=\"background-color:#F6F6F6;height:100%;\">'
								+'<img alt=\"\" src='+imgPath+' style=\"margin: 19% 42%;\">'
								+'<span style=\"font-size: 20px;font-weight: bold;float: right;margin: -15% 10%;\">您目前还没有参与任何项目测试，被设置到项目的测试流程中才被视为参与了该项目的测试工作</span></div>');
						mainObjs.$menu.parent().attr('style','display:block;');
						$(".content").removeClass('content_c').addClass('content');
					}
				}
				$("#caseItemList").xdatagrid('resize');
			},
			onClickRow:function(rowIndex, rowData){
				taskFlg = 0;
				sysTestFlg = 0;
				inerfaceFlg = 1;
				sysDieFlg = 0;
				sysConfigFlg = 0;
				projectTo=0;
				env=0;
				$("#changeProjectName").val("");
				$("#projectToJump").html("项目");
				$("#projectToJump").css("color","#e9f6ff");
				$("#projectToJump").prev().attr("src",baseUrl + '/itest/images/homeImage/projectTo.png');
				$('#iterL').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/iterList.png');
				$("#otherMissionssss").css("color","#e9f6ff");
				$("#otherMissionImg").attr('src',baseUrl+'/itest/images/homeImage/elseTs.png');
				$("#situationL").html("环境");
				$("#situationL").css("color","#e9f6ff");
				$("#situationL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/env.png');
				$("#changePro").html("测试");
				$('#changePro').removeAttr("title");
				$("#changePro").css("color","#e9f6ff");
				$("#changePro").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/switch.png');
				var dataU = $("#dataUrl").data('dataUrl');
				$("#menu").hide();
				$("#interfaceMenu").show();
				$("#leftMenu").show();
				$(".sidebary").show();
				$("#taksIdmain").val(rowData.taskId);
				$("#outlineState").val(rowData.outlineState);	
				//分析度量
				//将分析度量页面数据放入session
				$("#analyitemId").val(rowData.taskId); 
				$("#analyprojectName").val(rowData.proName); 
				$("#analyproNum").val(rowData.proNum); 
				putAnalysisSession(rowData.taskId,rowData.proName,rowData.proNum);
				$("#addMenus").css('marginLeft','5em');
				if($('#leftMenu').width()=='75'){
					$('#menu li span').hide();
					mainObjs.$logoImg.attr("data-show","2");
				}else{
					mainObjs.$logoImg.attr("data-show","1");
				}
				$('#interfaceL').html("");
				if(rowData.proName.length > 3){
					$('#interfaceL').html("接口 > "+rowData.proName.substring(0,2)+"...");
				}else{
					$('#interfaceL').html("接口 > "+rowData.proName);
				}
				$('#interfaceL').attr("title",rowData.proName);
				$('#interfaceL').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/interface1.png');
				$('#interfaceL').css('color','#ffffff');
				$(".l-menu").show();
				$(".content").removeClass('content_c').addClass('content');
				
				$("#otherMissionLeftMenu").hide();
				$("#caseTypeMenu").hide();
				$("#systemManage").css("color","#e9f6ff");
				$("#systemManage").html("设置");
				$("#systemM").css("margin","20px 0 -5px");
				
				removeLeftMenuEffect();
				//切换系统管理的效果
				systemManX();
				$("#caseItemWin").xwindow('close');
				if(!$("#i1").is(':hidden')){
					$("#i1").css("background","rgb(30, 124, 251) none repeat scroll 0% 0%");
					if($("#i1").children().children().attr("src").split("1").length > 1){
						$("#i1").children().children().attr("src",$("#i1").children().children().attr("src").split("1")[0]+".png");
					}
					$("#i1").siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
					interfaceId = "i1";
					mainObjs.$wrapPage.load(baseUrl + "/apiManager/apiManagerAction!testSceneView.action");
				}else if(!$("#i2").is(':hidden')){
					$("#i2").css("background","rgb(30, 124, 251) none repeat scroll 0% 0%");
					if($("#i2").children().children().attr("src").split("1").length > 1){
						$("#i2").children().children().attr("src",$("#i2").children().children().attr("src").split("1")[0]+".png");
					}
					$("#i2").siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
					interfaceId = "i2";
					mainObjs.$wrapPage.load(baseUrl + "/apiManager/apiManagerAction!interfaceManage.action");
				}else if(!$("#i3").is(':hidden')){
					$("#i3").css("background","rgb(30, 124, 251) none repeat scroll 0% 0%");
					if($("#i3").children().children().attr("src").split("1").length > 1){
						$("#i3").children().children().attr("src",$("#i3").children().children().attr("src").split("1")[0]+".png");
					}
					$("#i3").siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
					interfaceId = "i3";
					mainObjs.$wrapPage.load(baseUrl + "/apiManager/apiManagerAction!testSceneManage.action");
				}else if(!$("#i4").is(':hidden')){
					$("#i4").css("background","rgb(30, 124, 251) none repeat scroll 0% 0%");
					if($("#i4").children().children().attr("src").split("1").length > 1){
						$("#i4").children().children().attr("src",$("#i4").children().children().attr("src").split("1")[0]+".png");
					}
					$("#i4").siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
					interfaceId = "i4";
					mainObjs.$wrapPage.load(baseUrl + "/apiManager/apiCrontabAction!crontabManage.action");
				}

				
				//每15分钟更新下session
				updateSession();
			},
			columns:[[
				{field:'proNum',title:'项目编号',width:'20%',align:'left',halign:'center'},
				{field:'proName',title:'项目名称',width:'30%',align:'left',halign:'center'},
				{field:'psmName',title:'项目PM',width:'25%',align:'left',halign:'center'},
				{field:'status',title:'状态',width:'10%',align:'left',halign:'center',formatter:statusFormats},
				{field:'testLdVos',title:'测试负责人',width:'28.4%',align:'left',halign:'center',formatter:testerFormat}
			]],
		});
	
	},250);
}


//每15分钟更新一次
function updateSession(){
	intt = setInterval(function(){
		myrefresh();
	},900000);
}


function myrefresh(){
	var urls = baseUrl + '/commonAction!activeConn.action';
	$.ajax({
		  url: urls,
		  cache: false,
		  async: false,
		  type: "POST",
		  dataType:"text",
		  success: function(data){}});
}

//判断是否参与项目
function haveJoinProject(){
	$.ajaxSettings.async = false;
	var projectHaveFlag = false;
	$.post(baseUrl + '/singleTestTask/singleTestTaskAction!getTpProCount.action?dto.operCmd=caseList',null,function(data){
		if(data.total > 0){
			if(data.total==1){
				var taskInfoArr= data.countProName.split("-");
				onlyOneTaskName = taskInfoArr[1];
				onlyOneTaskId = taskInfoArr[0];
				$("#taksIdmain").val(onlyOneTaskId);
				$("#outlineState").val(taskInfoArr[2]);	
				//分析度量
				//将分析度量页面数据放入session
				$("#analyitemId").val(onlyOneTaskId); 
				$("#analyprojectName").val(onlyOneTaskName); 
				$("#analyproNum").val(taskInfoArr[3]); 
				putAnalysisSession(onlyOneTaskId,onlyOneTaskName,taskInfoArr[3]);
			}
			projectHaveFlag = true;
		}else{
			projectHaveFlag = false;
			onlyOneTaskName = "";
			onlyOneTaskId = "";
		}
	},'json');   
	return projectHaveFlag;
}

function testerFormat(value,row,index) { 
	var html = new Array();
	if (row.testLdVos!=null&&row.testLdVos.length) {
		for (var i = 0; i < row.testLdVos.length; i++) {
			html.push(row.testLdVos[i].name);
		}
	}
	return html.join(',');
}

//放taskId在session
function putTaskIdSession(taskId){
	var urls = baseUrl + '/singleTestTask/singleTestTaskAction!putTaskIdSession.action?dto.isAjax=true';
	$.ajax({
		  url: urls,
		  cache: false,
		  async: false,
		  type: "POST",
		  dataType:"text",
		  data: {
			  	"dto.singleTest.taskId":taskId
			  	},
		  success: function(data){
			  if(data.indexOf("success")>=0){

			  }else{
				  tipPermission("系统问题！");
			  }
		  }
		});
}

//将分析度量页面数据放入session
function putAnalysisSession(taskId,proName,proNum){
	var urls = baseUrl + '/analysis/analysisAction!putAnanysisSession.action?dto.isAjax=true';
	$.ajax({
		  url: urls,
		  cache: false,
		  async: false,
		  type: "POST",
		  dataType:"text",
		  data: {
			  	"analysisDto.taskId":taskId,
			  	"analysisDto.analyProjectName":proName,
			  	"analysisDto.analyProNum":proNum
			  	},
		  success: function(data){
			  if(data.indexOf("success")>=0){
			  }else{
				  tipPermission("系统问题！");
			  }
		  }
		});
			
}

function statusFormats(value,row,index) {
	switch (value) {
	case 0:
		return '进行中';
	case 1:
		return '完成';
	case 2:
		return '结束';
	case 3:
		return '准备';
	case 5:
		return '暂停';
	case 6:
		return '终止';
	default:
		return '-';
	}
}

//定位到用例管理
function exampleManager(datas,url){
	if(datas!=''){ //只有一个项目时，从其他菜单再跳回来时，这里是空，不能设置值
		$("#taksIdmain").val(datas.taskId);
	}
	$("#caseItemWin").xwindow('close');
	var urlSplit = url.split("^");
	if($("#outlineState").val()!='0'){
		$("#"+urlSplit[0]).css('background','#1e7cfb');
		$("#"+urlSplit[0]).siblings().css('background','#3d4351');
		$("#"+urlSplit[0]).find('img').attr('src',urlSplit[1]);
		$("#"+urlSplit[0]).find('span').css('color','#ffffff');
		mainObjs.$wrapPage.load(baseUrl + urlSplit[2]);
	}else{
		$.xalert({title:'提示',msg:'因测试需求没提交，请提交测试需求!',okFn:function(){
			$("#"+urlSplit[0]).css('background','');
			$("#"+urlSplit[0]).find('img').attr('src',baseUrl+"/itest/images/homeImage/defect1.png");
			$("#"+urlSplit[0]).find('span').css('color','#E9F6FF');
			
			$("#menu_68").css('background','#1e7cfb');
			$("#menu_68").find('img').attr('src',baseUrl+"/itest/images/homeImage/projectMan.png");
			$("#menu_68").find('span').css('color','#ffffff');
			mainObjs.$wrapPage.load(baseUrl + "/outLineManager/outLineAction!index.action");
		}});
	}
}

//定位到缺陷管理里
function defectManager(data){
	$("#caseItemWin").xwindow('close');
	var home_Urls = $("#myhome").data("myHome");
	if(home_Urls!=undefined  && home_Urls.indexOf("otherMission") == -1 && home_Urls.indexOf("apiManager") == -1){
		if(home_Urls.indexOf("loadAllMyBug.action")>=0){
			//缺陷管理
			$("#menu_107").attr('style','background: rgb(30, 124, 251);');
			$("#menu_107").find('img').removeAttr('src');
			$("#menu_107").find('img').attr('src',baseUrl+"/itest/images/homeImage/defect.png");
			$("#menu_107").find('span').css('color','#ffffff');
		}else if(home_Urls.indexOf("goAnalysisMain.action")>=0){
			//分析度量
			$("#menu_143").attr('style','background: rgb(30, 124, 251);');
			$("#menu_143").find('img').removeAttr('src');
			$("#menu_143").find('img').attr('src',baseUrl+"/itest/images/homeImage/analysis.png");
			$("#menu_143").find('span').css('color','#ffffff');
		}else if(home_Urls.indexOf("loadCase.action")>=0){
			//测试用例管理
			$("#menu_87").attr('style','background: rgb(30, 124, 251);');
			$("#menu_87").find('img').removeAttr('src');
			$("#menu_87").find('img').attr('src',baseUrl+"/itest/images/homeImage/testSin.png");
			$("#menu_87").find('span').css('color','#ffffff');
		}else if(home_Urls.indexOf("index.action")>=0){
			//测试需求管理
			$("#menu_68").attr('style','background: rgb(30, 124, 251);');
			$("#menu_68").find('img').removeAttr('src');
			$("#menu_68").find('img').attr('src',baseUrl+"/itest/images/homeImage/projectMan.png");
			$("#menu_68").find('span').css('color','#ffffff');
		}else if(home_Urls.indexOf("overviewAction")>=0){
			//总览
			$("#menu_13").attr('style','background: rgb(30, 124, 251);');
			$("#menu_13").find('img').removeAttr('src');
			$("#menu_13").find('img').attr('src',baseUrl+"/itest/images/homeImage/zl.png");
			$("#menu_13").find('span').css('color','#ffffff');
		}else /*if(homeUrl.indexOf("goTestCasePkgMain.action")>=0)*/{
			//缺陷管理
			$("#menu_11").attr('style','background: rgb(30, 124, 251);');
			$("#menu_11").find('img').removeAttr('src');
			$("#menu_11").find('img').attr('src',baseUrl+"/itest/images/homeImage/testcasepkg.png");
			$("#menu_11").find('span').css('color','#ffffff');
		}
		mainObjs.$wrapPage.load(baseUrl +$("#myhome").data("myHome").split("&")[0]);
	}else{
		$("#menu_13").css('background','#1e7cfb');
		$("#menu_13").find('img').attr('src',baseUrl + '/itest/images/homeImage/zl.png');
		$("#menu_13").find('span').css('color','#ffffff');
//		mainObjs.$wrapPage.load(baseUrl + "/bugManager/bugManagerAction!loadAllMyBug.action?dto.allTestTask=true");
		mainObjs.$wrapPage.load(baseUrl + "/overview/overviewAction!loadInformation.action");
	}
	
}

//logo跳到主页去
function logoEvent(){
	destoryEle();
	mainObjs.$wrapPage.empty();
	$("#projectToJump").html("项目");
	$("#projectToJump").css("color","#e9f6ff");
	$("#projectToJump").prev().attr("src",baseUrl + '/itest/images/homeImage/projectTo.png');
	
	$("#changePro").html("测试");
	$('#changePro').removeAttr("title");
	$("#changePro").css("color","#e9f6ff");
	$("#changePro").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/switch.png');
	
	$("#systemManage").html("设置");
	$("#systemManage").css("color","#e9f6ff");
	$("#systemManage").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/systemM.png');
	
	$("#otherMissionssss").html("任务");
	$("#otherMissionssss").css("color","#e9f6ff");
	$("#otherMissionssss").prev().attr("src",baseUrl + '/itest/images/homeImage/elseTs.png');
	
	$("#iterL").html("迭代");
	$("#iterL").css("color","#e9f6ff");
	$("#iterL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/iterList.png');
	
	
	$("#leftMenu").hide();
	$(".sidebary").hide();
	
	$(".content").addClass('content_c');
	mainObjs.$wrapPage.load(baseUrl + "/itest/jsp/itestManual/itestManual.jsp");
}



function bindSystemMenu(){
	var sysMenus = $(".systemM li");
	if(sysMenus.length>=0){
		for(var i=0; i<sysMenus.length;i++){
			sysMenus[i].addEventListener("click",function(){
				clearInterval(intt);
				var targetId = this.id;
				var id = targetId.substr(7);
				
				$("#projectToJump").html("项目");
				$("#projectToJump").css("color","#e9f6ff");
				$("#projectToJump").prev().attr("src",baseUrl + '/itest/images/homeImage/projectTo.png');
				
				$("#situationL").html("环境");
				$("#situationL").css("color","#e9f6ff");
				$("#situationL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/env.png');
				
				$("#systemM").css('marginLeft','2.5em');
				$('#changePro').html("测试");
				$('#changePro').removeAttr("title");
				$('#changePro').css('color','#E9F6FF');
				
				$("#interfaceL").html("接口");
				$('#interfaceL').removeAttr("title");
				$("#interfaceL").css("color","#e9f6ff");
				$("#interfaceL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/interface.png');
				
				$("#otherMissionssss").css("color","#e9f6ff");
				$("#otherMissionImg").attr('src',baseUrl+'/itest/images/homeImage/elseTs.png');
				$('#iterL').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/iterList.png');
				$("#addMenus").css("margin","20px 0 -5px");
				$('#changePro').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/switch.png');
				
				if(id!=""){
					var targetUrl = systemMenusArr[id].url;
					var functionName = systemMenusArr[id].functionName;
					var functionShortName = "";
					if(functionName.length>4){
						functionShortName = functionName.substring(0,3)+"..";
					}else{
						functionShortName = functionName;
					}
					functionName = "<span title='"+functionName+"'>"+functionShortName+"</span>"
					$("#systemMenu > a").find('span[class="switchSt"] label').html("设置 > "+functionName);
					$("#systemMenu > a").find('span[class="switchSt"] label').css('color','#ffffff');
					$("#systemMenu > a").find('span[class="switchSt"]').prev().attr('src',baseUrl + '/itest/images/homeImage/systemM1.png');
					
					if (targetUrl) {
						$(".sidebary").hide();
						$(".l-menu").hide();
						$(".content").addClass('content_c');
						destoryEle();
						taskFlg = 0;
						sysTestFlg = 0;
						sysDieFlg = 0;
						sysConfigFlg = 1;
						inerfaceFlg = 0;
						projectTo=0;
						env=0;
						mainObjs.$wrapPage.load(baseUrl + targetUrl);
						mainObjs.$logoImg.attr("data-show","3");
						$(".systemMenu").css('display','none');
					}
				}else{
					if($(this).attr("idValue")=='caseLib'){
						//用例库
						testLibrary();
					}else if($(this).attr("idValue")=='upDb'){
						upDb();
					}else if($(this).attr("idValue")=='removeDemoData'){
						removeDemoData();
					}else if($(this).attr("idValue")=='ldapAccountSyn'){
						ldapAccountSynTip();
					}else if($(this).attr("idValue")=='ldapServerConfig'){
						ldapServerConfigAdd();
					}
					
					$(".systemMenu").css('display','none');
				}
				
			});
		}
	}
	
}

//ldap账户同步
function ldapAccountSynTip(){
	$.xconfirm({
		msg:"确定要同步LDAP账户吗？",
		okFn: function() {
			var urls = baseUrl + "/ldapVerification/ldapVerificationAction!getLdapAllUserInfo.action";
			$.ajax({
				  url: urls,
				  cache: false,
				  async: false,
				  type: "POST",
				  dataType:"text",
				  success: function(data){
					  if(data.indexOf("success")>=0){
						  $.xalert({title:'提示',msg:'LDAP账户同步成功!'});
					  }else{
						   $.xalert({title:'提示',msg:'LDAP SERVER连接不上，请检查服务配置信息!'});
					  }
				  }
				});
		},cancelFn: function(){
			 
		}
	});
}

//升级数据库
function upDb(){
	$.xconfirm({
		msg:'每当升级安装后执行一次，请确认',
		okFn: function() {
			$.ajax({
				  url: baseUrl + '/commonAction!execSql.action',
				  cache: false,
				  async: false,
				  type: "POST",
				  dataType:"text",
				  success: function(data){
					  $.xalert({title:'提示',msg:'升级成功,请重新登录!'});
					  //window.parent.location.href= baseUrl + "/login.htm?logOut=true";
				  }});
		}
	});
}
//清demo数据
function removeDemoData(){
	$.xconfirm({
		msg:'安装一周后方可清除，且没有使用demo帐户操作非demo项目的数据才能清除成功，请确认是否要清除demo数据!',
		okFn: function() {
			$.ajax({
				  url: baseUrl + '/commonAction!cleanDemo.action',
				  cache: false,
				  async: false,
				  type: "POST",
				  dataType:"text",
				  success: function(data){
					  if(data.indexOf("success")>=0){
						  $.xalert({title:'提示',msg:'成功清除demo数据，请重新登录!'});
					  }else{
						  if(data.indexOf("nothing to do")>=0){
							  $.xalert({title:'提示',msg:'此前己清除过，不再执行清除!'});
						  }else if(data.indexOf("unknow installed date ")>=0){
							  $.xalert({title:'提示',msg:'安装日期未知，不执行清除demo数据!'});
						  }else if(data.indexOf(" date of install format is error ")>=0){
							  $.xalert({title:'提示',msg:'安装日期格式错误，不执行清除demo数据!'});
						  }else if(data.indexOf("installed is not enough one week  ")>=0){
							  $.xalert({title:'提示',msg:'安装不足一周，不执行清除demo数据!'});
						  }else {
							  $.xalert({title:'提示',msg:'未执行清除demo数据!'});
						  }
						 
					  }
					 
					  //window.parent.location.href= baseUrl + "/login.htm?logOut=true";
				  }});
		}
	});
}
//点击迭代列表
function switchToDiedai(){
	$(".sidebary").hide();
	$("#leftMenu").hide();
	destoryEle();
	mainObjs.$wrapPage.empty();
	setTimeout(function(){ 
		mainObjs.$wrapPage.load(baseUrl + "/iteration/iterationAction!iterationList.action",null,function(){
			
			$("#projectToJump").html("项目");
			$("#projectToJump").css("color","#e9f6ff");
			$("#projectToJump").prev().attr("src",baseUrl + '/itest/images/homeImage/projectTo.png');
			
			$("#changePro").html("测试");
			$('#changePro').removeAttr("title");
			$("#changePro").css("color","#e9f6ff");
			$("#changePro").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/switch.png');
			
			$("#interfaceL").html("接口");
			$('#interfaceL').removeAttr("title");
			$("#interfaceL").css("color","#e9f6ff");
			$("#interfaceL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/interface.png');
			
			$("#systemManage").html("设置");
			$("#systemManage").css("color","#e9f6ff");
			$("#systemManage").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/systemM.png');
			
			$("#otherMissionssss").html("任务");
			$("#otherMissionssss").css("color","#e9f6ff");
			$("#otherMissionssss").prev().attr("src",baseUrl + '/itest/images/homeImage/elseTs.png');
			
			$("#situationL").html("环境");
			$("#situationL").css("color","#e9f6ff");
			$("#situationL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/env.png');
		});
	},250);
	$(".content").addClass('content_c');
	$('#iterL').css('color','#ffffff');
	$('#iterL').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/iterList1.png');
	//destoryEle();
	mainObjs.$logoImg.attr("data-show","3");
	taskFlg = 0;
	sysTestFlg = 0;
	inerfaceFlg = 0;
	sysDieFlg = 1;
	sysConfigFlg = 0;
	projectTo=0;
	env = 0;
	$("#navFlag").data("navFlag","itera");
	//每15分钟更新下session
	updateSession();
}

//去掉左边菜单点亮的效果
function removeLeftMenuEffect(){
	var allLi = mainObjs.$menu.find('li');
	$.each(allLi,function(i,n){
		var firstD ="";
		var currPic = $("#"+allLi[i].id).find('a > img').attr('src');
		var picPath = currPic.split(".png");
		if($("#"+allLi[i].id).attr('style')!=undefined){
			firstD = $("#"+allLi[i].id).attr('style').indexOf('background: rgb(30, 124, 251)');
			if(firstD>=0){
				if(id!=allLi[i].id){
					$("#"+allLi[i].id).attr('style','');
					$("#"+allLi[i].id).find('img').attr('src',picPath[0]+"1.png");
					$("#"+allLi[i].id).find('span').css('color','#E9F6FF');
				}
				$("#navTop").data('effect',"noEf");
			}
		}
		
	});
}


//点击测试项目管理
function testItems(){
	clearInterval(intt);
	//去掉左边菜单点亮的效果
//	removeLeftMenuEffect();
	$("#menu").show();
	$(".sidebary").hide();
	$("#otherMissionLeftMenu").hide();
	$("#caseTypeMenu").hide();
	$("#interfaceMenu").hide();
	$("#systemManage").css("color","#e9f6ff");
	$("#systemManage").html("设置 ");
	$("#systemM").css("margin","20px 0 -5px");
	$("#otherMissionssss").css("color","#e9f6ff");
	$("#otherMissionImg").attr('src',baseUrl+'/itest/images/homeImage/elseTs.png');
	$(".l-menu").hide();
	$(".content").addClass('content_c');
	$("#changePro").html("测试");
	$('#changePro').removeAttr("title");
	$("#changePro").css("color","#e9f6ff");
	$("#changePro").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/switch.png');
	$("#interfaceL").html("接口");
	$('#interfaceL').removeAttr("title");
	$("#interfaceL").css("color","#e9f6ff");
	$("#interfaceL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/interface.png');
	$("#systemManage").html("设置");
	$("#systemManage").css("color","#e9f6ff");
	$("#systemManage").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/systemM.png');
	$("#otherMissionssss").html("任务");
	$("#otherMissionssss").css("color","#e9f6ff");
	$("#otherMissionssss").prev().attr("src",baseUrl + '/itest/images/homeImage/elseTs.png');
	$("#situationL").html("环境");
	$("#situationL").css("color","#e9f6ff");
	$("#situationL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/env.png');
	$('#iterL').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/iterList.png');
	//切换系统管理的效果
//	systemManX();
	destoryEle();
	mainObjs.$wrapPage.empty();
	setTimeout(function(){ 
		mainObjs.$wrapPage.load(baseUrl + "/singleTestTask/singleTestTaskAction!projectList.action");
	},250);
	projectTo=1;
	taskFlg = 0;
	sysTestFlg = 0;
	sysDieFlg = 0;
	sysConfigFlg = 0;
	env = 0;
	inerfaceFlg=0;
	mainObjs.$logoImg.attr("data-show","3");
}

function switchToEnv() {
	clearInterval(intt);
	//去掉左边菜单点亮的效果
//	removeLeftMenuEffect();
	$("#menu").hide();
	$(".sidebary").hide();
	$("#otherMissionLeftMenu").hide();
	$("#caseTypeMenu").hide();
	$("#interfaceMenu").hide();
	$("#systemManage").css("color","#e9f6ff");
	$("#systemManage").html("设置 ");
	$("#systemM").css("margin","20px 0 -5px");
	$("#otherMissionssss").css("color","#e9f6ff");
	$("#otherMissionImg").attr('src',baseUrl+'/itest/images/homeImage/elseTs.png');
	$(".l-menu").hide();
	$(".content").addClass('content_c');
	$("#changePro").html("测试");
	$('#changePro').removeAttr("title");
	$("#changePro").css("color","#e9f6ff");
	$("#changePro").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/switch.png');
	
	$("#interfaceL").html("接口");
	$('#interfaceL').removeAttr("title");
	$("#interfaceL").css("color","#e9f6ff");
	$("#interfaceL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/interface.png');
	
	$("#systemManage").html("设置");
	$("#systemManage").css("color","#e9f6ff");
	$("#systemManage").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/systemM.png');
	
	$("#otherMissionssss").html("任务");
	$("#otherMissionssss").css("color","#e9f6ff");
	$("#otherMissionssss").prev().attr("src",baseUrl + '/itest/images/homeImage/elseTs.png');
	
	$("#projectToJump").html("项目");
	$("#projectToJump").css("color","#e9f6ff");
	$("#projectToJump").prev().attr("src",baseUrl + '/itest/images/homeImage/projectTo.png');
	
	$('#iterL').css('color','#ffffff');
	$('#iterL').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/iterList.png');
	
	
	$('#situationL').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/env1.png');
	destoryEle();
	mainObjs.$wrapPage.empty();
	mainObjs.$wrapPage.load(baseUrl + "/env/envAction!envList.action");

	projectTo=0;
	taskFlg = 0;
	sysTestFlg = 0;
	inerfaceFlg = 0;
	sysDieFlg = 0;
	sysConfigFlg = 0;
	env = 1;
	mainObjs.$logoImg.attr("data-show","3");
}
//点击测试用例库
function testLibrary(){
	$(".sidebary").show();
	destoryEle();
	mainObjs.$wrapPage.empty();
	clearInterval(intt);
	$("#menu").hide();
	$("#otherMissionLeftMenu").hide();
	$("#caseTypeMenu").show();
	$("#interfaceMenu").hide();
	$("#otherMissionssss").css("color","#e9f6ff");
	$("#otherMissionImg").attr('src',baseUrl+'/itest/images/homeImage/elseTs.png');
	$(".l-menu").show();
	$(".content").removeClass('content_c').addClass('content');
	
	$("#systemMenu > a").find('span[class="switchSt"] label').html("设置 > 用例库");
	$("#systemMenu > a").find('span[class="switchSt"] label').css('color','#ffffff');
	$("#systemMenu > a").find('span[class="switchSt"]').prev().attr('src',baseUrl + '/itest/images/homeImage/systemM1.png');
	$('#changePro').html("");
	$('#changePro').html("测试 ");
	$('#changePro').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/switch.png');
	
	$('#iterL').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/iterList.png');
	destoryEle();
	if($("#isAdmin").text() == "2" || $("#isAdmin").text() == "1"){
		$("#l2").css("background","rgb(30, 124, 251) none repeat scroll 0% 0%");
		if(casId){
			$("#"+casId).children().children().attr("src",$("#"+casId).children().children().attr("src").split(".png")[0]+"1.png");
		}
		if($("#l2").children().children().attr("src").split("1").length > 1){
			$("#l2").children().children().attr("src",$("#l2").children().children().attr("src").split("1")[0]+".png");
		}
		$("#l2").siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
		mainObjs.$wrapPage.load(baseUrl + "/testLibrary/testLibraryAction!caseLook.action");

		//跳转测试用例库时，将data-show设为7，用于区分左边菜单收缩效果
		mainObjs.$logoImg.attr("data-show","7");
		taskFlg = 0;
		sysTestFlg = 0;
		sysDieFlg = 0;
		sysConfigFlg = 1;
		env = 0;
		inerfaceFlg=0;
		projectTo=0;
		casId = "l2";
	}else{
		$("#l2").css("background","rgb(30, 124, 251) none repeat scroll 0% 0%");
		if(casId){
			$("#"+casId).children().children().attr("src",$("#"+casId).children().children().attr("src").split(".png")[0]+"1.png");
		}
		if($("#l2").children().children().attr("src").split("1").length > 1){
			$("#l2").children().children().attr("src",$("#l2").children().children().attr("src").split("1")[0]+".png");
		}
		$("#l2").siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
		mainObjs.$wrapPage.load(baseUrl + "/testLibrary/testLibraryAction!caseLook.action");
		//跳转测试用例库时，将data-show设为7，用于区分左边菜单收缩效果
		mainObjs.$logoImg.attr("data-show","7");
		taskFlg = 0;
		sysTestFlg = 0;
		sysDieFlg = 0;
		sysConfigFlg = 1;
		inerfaceFlg=0;
		projectTo=0;
		env = 0;
		casId = "l2";
	}
}
//切换系统管理的效果
function systemManX(){
	$("#systemMenu > a").find('span[class="switchSt"] label').html("设置 ");
	$("#systemMenu > a").find('span[class="switchSt"] label').css('color','#E9F6FF');
	$("#systemMenu > a").find('span[class="switchSt"]').prev().attr('src',baseUrl + '/itest/images/homeImage/systemM.png');
}
	
//注销
function exitLogin(){
	$.xconfirm({
		msg:'您确定退出吗?',
		okFn: function() {
			window.parent.location.href= baseUrl + "/login.htm?logOut=true";
		}
	});
}
//跳转到其他任务页面
function switchToOtherMission(){
	$(".sidebary").show();
	destoryEle();
	clearInterval(intt);
	$(".l-menu").show();
	$(".content").removeClass('content_c').addClass('content');
	//跳转到其他任务时，将data-show设为5，用于区分左边菜单收缩效果
	mainObjs.$logoImg.attr("data-show","5");
	taskFlg = 1;
	sysTestFlg = 0;
	inerfaceFlg = 0;
	sysDieFlg = 0;
	sysConfigFlg = 0;
	projectTo=0;
	env = 0;
	$("#menu").hide();
	$("#otherMissionLeftMenu").show();
	$("#caseTypeMenu").hide();
	$("#interfaceMenu").hide();
	$("#otherMissionssss").css("color","#ffffff");
	$("#otherMissionImg").attr('src',baseUrl+'/itest/images/homeImage/elseTs1.png');
	$("#changePro").css("color","#e9f6ff");
	$("#changePro").html("测试");
	$('#changePro').removeAttr("title");
	$("#addMenus").css("margin","20px 0 -5px");
	$("#systemM").css("margin","20px 0 -5px");
	$("#systemManage").css("color","#e9f6ff");
	$("#systemManage").html("设置 ");
	$('#iterL').css('color','#ffffff');
	$('#iterL').parent().prev().attr('src',baseUrl + '/itest/images/homeImage/iterList.png');
	
	$("#projectToJump").html("项目");
	$("#projectToJump").css("color","#e9f6ff");
	$("#projectToJump").prev().attr("src",baseUrl + '/itest/images/homeImage/projectTo.png');
	
	$("#changePro").html("测试");
	$('#changePro').removeAttr("title");
	$("#changePro").css("color","#e9f6ff");
	$("#changePro").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/switch.png');
	
	$("#interfaceL").html("接口");
	$('#interfaceL').removeAttr("title");
	$("#interfaceL").css("color","#e9f6ff");
	$("#interfaceL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/interface.png');
	
	$("#situationL").html("环境");
	$("#situationL").css("color","#e9f6ff");
	$("#situationL").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/env.png');
	
	$("#systemManage").html("设置");
	$("#systemManage").css("color","#e9f6ff");
	$("#systemManage").parent().prev().attr("src",baseUrl + '/itest/images/homeImage/systemM.png');
	$("#m1").css("background","rgb(30, 124, 251) none repeat scroll 0% 0%");
	if(otherId){
		$("#"+otherId).children().children().attr("src",$("#"+otherId).children().children().attr("src").split(".png")[0]+"1.png");
	}
	if($("#m1").children().children().attr("src").split("1").length > 1){
		$("#m1").children().children().attr("src",$("#m1").children().children().attr("src").split("1")[0]+".png");
	}
	$("#m1").siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
	mainObjs.$wrapPage.load(baseUrl + "/otherMission/otherMissionAction!overview.action");
	otherId = "m1";
}
//跳转到看板页面
function overview(obj){
	destoryEle();
	$(obj).css('background', 'rgb(30, 124, 251) none repeat scroll 0% 0%');
	$(obj).siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
	if(otherId != obj.id){
		$("#"+otherId).children().children().attr("src",$("#"+otherId).children().children().attr("src").split(".png")[0]+"1.png");
	}
	mainObjs.$wrapPage.load(baseUrl + "/otherMission/otherMissionAction!overview.action");
	otherId = obj.id;
}
//跳转到我负责的其他任务页面
function toMeCharge(obj){
	destoryEle();
	$(obj).css('background', 'rgb(30, 124, 251) none repeat scroll 0% 0%');
	$(obj).siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
	if(otherId != obj.id){
		$("#"+otherId).children().children().attr("src",$("#"+otherId).children().children().attr("src").split(".png")[0]+"1.png");
	}
	mainObjs.$wrapPage.load(baseUrl + "/otherMission/otherMissionAction!toMeCharge.action");
	otherId = obj.id;
}
//跳转到我参与的其他任务页面
function toMeJoin(obj){
	destoryEle();
	$(obj).css('background', 'rgb(30, 124, 251) none repeat scroll 0% 0%');
	$(obj).siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
	if(otherId != obj.id){
		$("#"+otherId).children().children().attr("src",$("#"+otherId).children().children().attr("src").split(".png")[0]+"1.png");
	}
	mainObjs.$wrapPage.load(baseUrl + "/otherMission/otherMissionAction!toMeJoin.action");
	otherId = obj.id;
}
//跳转到我创建的其他任务页面
function toMeCreate(obj){
	destoryEle();
	$(obj).css('background', 'rgb(30, 124, 251) none repeat scroll 0% 0%');
	$(obj).siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
	if(otherId != obj.id){
		$("#"+otherId).children().children().attr("src",$("#"+otherId).children().children().attr("src").split(".png")[0]+"1.png");
	}
	mainObjs.$wrapPage.load(baseUrl + "/otherMission/otherMissionAction!otherMissionList.action");
	otherId = obj.id;
}
//跳转到我关注的其他任务页面
function toMeConcern(obj){
	destoryEle();
	$(obj).css('background', 'rgb(30, 124, 251) none repeat scroll 0% 0%');
	$(obj).siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
	if(otherId != obj.id){
		$("#"+otherId).children().children().attr("src",$("#"+otherId).children().children().attr("src").split(".png")[0]+"1.png");
	}
	mainObjs.$wrapPage.load(baseUrl + "/otherMission/otherMissionAction!toMeConcern.action");
	otherId = obj.id;
}
//跳转到所有其他任务页面
function allMission(obj){
	destoryEle();
	$(obj).css('background', 'rgb(30, 124, 251) none repeat scroll 0% 0%');
	$(obj).siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
	if(otherId != obj.id){
		$("#"+otherId).children().children().attr("src",$("#"+otherId).children().children().attr("src").split(".png")[0]+"1.png");
	}
	mainObjs.$wrapPage.load(baseUrl + "/otherMission/otherMissionAction!allMissions.action");
	otherId = obj.id;
}

//跳转到设置的接口首页
function apiManagerFirstPage(hurl){
	var UrlSp = hurl.split("&");
	var homeUrl = UrlSp[0];
	$("#taksIdmain").val(UrlSp[1].split("=")[1]);
	$(".sidebary").show();
	$(".l-menu").show();
	$(".content").removeClass('content_c').addClass('content');
	mainObjs.$logoImg.attr("data-show","6");
	$("#menu").hide();
	$("#interfaceMenu").show();
	$("#otherMissionLeftMenu").hide();
	$("#caseTypeMenu").hide();
	$("#interfaceL").css("color","#ffffff");
	$("#interfaceImg").attr('src',baseUrl+'/itest/images/homeImage/interface1.png');
	inerfaceFlg = 1;
//	taskFlg = 1;
//	$("#interfaceL").css("color","#e9f6ff");
//	$("#interfaceL").html("接口");
	$('#interfaceL').removeAttr("title");
	$("#addMenus").css("margin","20px 0 -5px");
	$("#systemM").css("margin","20px 0 -5px");
	$("#systemManage").css("color","#e9f6ff");
	$("#systemManage").html("设置 ");
	$("#interfaceMenu").find("li[myUrl='"+homeUrl+"']").css("background","rgb(30, 124, 251) none repeat scroll 0% 0%");
	if($("#interfaceMenu").find("li[myUrl='"+homeUrl+"']").children().children().attr("src").split("1").length > 1){
		$("#interfaceMenu").find("li[myUrl='"+homeUrl+"']").children().children().attr("src",$("#interfaceMenu").find("li[myUrl='"+homeUrl+"']").children().children().attr("src").split("1")[0]+".png");
	}
	$("#interfaceMenu").find("li[myUrl='"+homeUrl+"']").siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
	interfaceId = $("#interfaceMenu").find("li[myUrl='"+homeUrl+"']").attr("id");
	destoryEle();
	mainObjs.$wrapPage.load(baseUrl + homeUrl);
}


//跳转到设置的其他任务
function otherMissionFirstPage(hurl){
	$(".sidebary").show();
	$(".l-menu").show();
	$(".content").removeClass('content_c').addClass('content');
	//跳转到其他任务时，将data-show设为5，用于区分左边菜单收缩效果
	mainObjs.$logoImg.attr("data-show","5");
	$("#menu").hide();
	$("#otherMissionLeftMenu").show();
	$("#caseTypeMenu").hide();
	$("#interfaceMenu").hide();
	$("#otherMissionssss").css("color","#ffffff");
	$("#otherMissionImg").attr('src',baseUrl+'/itest/images/homeImage/elseTs1.png');
	taskFlg = 1;
	$("#changePro").css("color","#e9f6ff");
	$("#changePro").html("测试");
	$('#changePro').removeAttr("title");
	$("#addMenus").css("margin","20px 0 -5px");
	$("#systemM").css("margin","20px 0 -5px");
	$("#systemManage").css("color","#e9f6ff");
	$("#systemManage").html("设置 ");
	$("#otherMissionLeftMenu").find("li[myUrl='"+hurl+"']").css("background","rgb(30, 124, 251) none repeat scroll 0% 0%");
	if($("#otherMissionLeftMenu").find("li[myUrl='"+hurl+"']").children().children().attr("src").split("1").length > 1){
		$("#otherMissionLeftMenu").find("li[myUrl='"+hurl+"']").children().children().attr("src",$("#otherMissionLeftMenu").find("li[myUrl='"+hurl+"']").children().children().attr("src").split("1")[0]+".png");
	}
	$("#otherMissionLeftMenu").find("li[myUrl='"+hurl+"']").siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
	otherId = $("#otherMissionLeftMenu").find("li[myUrl='"+hurl+"']").attr("id");
	destoryEle();
	mainObjs.$wrapPage.load(baseUrl + hurl);
}
//跳转到测试场景总览/接口用例管理/测试场景管理
function pageSwitch(obj){
	destoryEle();
	$(obj).css('background', 'rgb(30, 124, 251) none repeat scroll 0% 0%');
	$(obj).siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
	if(interfaceId != obj.id){
		$("#"+interfaceId).children().children().attr("src",$("#"+interfaceId).children().children().attr("src").split(".png")[0]+"1.png");
	}
	var url = $(obj).attr("myUrl");
	mainObjs.$wrapPage.load(baseUrl + url);
	interfaceId = obj.id;
}
//跳转到接口用例管理
function interfaceManage(obj){
	
}
//跳转到测试场景管理
function testSceneManage(obj){
	
}
//跳转到用例类别维护
function caseTypeEdit(obj){
	destoryEle();
	$(obj).css('background', 'rgb(30, 124, 251) none repeat scroll 0% 0%');
	$(obj).siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
	if(casId != obj.id){
		$("#"+casId).children().children().attr("src",$("#"+casId).children().children().attr("src").split(".png")[0]+"1.png");
	}
	mainObjs.$wrapPage.load(baseUrl + "/testLibrary/testLibraryAction!loadTree.action");
	casId = obj.id;
}
//跳转到用例浏览
function caseLook(obj){
	destoryEle();
	$(obj).css('background', 'rgb(30, 124, 251) none repeat scroll 0% 0%');
	$(obj).siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
	if(casId != obj.id){
		$("#"+casId).children().children().attr("src",$("#"+casId).children().children().attr("src").split(".png")[0]+"1.png");
	}
	mainObjs.$wrapPage.load(baseUrl + "/testLibrary/testLibraryAction!caseLook.action");
	casId = obj.id;
}
//跳转到入库审核
function caseExamine(obj){
	destoryEle();
	$(obj).css('background', 'rgb(30, 124, 251) none repeat scroll 0% 0%');
	$(obj).siblings().css('background', 'rgb(61, 67, 81) none repeat scroll 0% 0%');
	if(casId != obj.id){
		$("#"+casId).children().children().attr("src",$("#"+casId).children().children().attr("src").split(".png")[0]+"1.png");
	}
	mainObjs.$wrapPage.load(baseUrl + "/testLibrary/testLibraryAction!caseExamine.action");
	casId = obj.id;
}


//获取当前用户的权限
function getLoginUserProManager(){
	$.ajaxSettings.async = false;
	//从后台取得权限，放入privilegeMap
	$.getJSON(
			baseUrl + '/userManager/userManagerAction!getUserUrls.action',
			function(data) {
				if(data.length > 0){
					for(var i=0;i<data.length;i++){
						privilegeMap[data[i]] ="1";
					}
				}
				var controlButton = $('li[schkUrl]');
				$.each(controlButton,function(i,n){
					var controId = controlButton[i].id;
					var controlUrl = $(controlButton[i]).attr('schkUrl');
					if(privilegeMap[controlUrl]!="1"){
						$("#"+controId).hide();
					}else{
						$("#"+controId).show();
					}
				});
				
				var controlDiv = $('div[schkUrl]');
				$.each(controlDiv,function(i,n){
					var controId = controlDiv[i].id;
					var controlUrl = $(controlDiv[i]).attr('schkUrl');
					if(privilegeMap[controlUrl]!="1"){
						$("#"+controId).hide(); 
					}else{
						$("#"+controId).show(); 
					}
				});
			}
	);
}

function notAllowInput(){
	$("input[type='password']").on("keypress",function(event){
		if(event.charCode == 32){
			return false;
		}
	});
}
function judgeAllSpace(str){
	var i =0;
	for(i=0;i<str.length;i++){
		if(str[0]!=" "&&str[str.length]!=" "){
			return false
			break;
		}else if(str[i]==" "){
			return true
		}
	}
}

//查询ldap的记录
function findLdapRecord(){
	var flg = false;
	$.post(
			baseUrl + "/ldapConfigInfo/ldapConfigInfoAction!findLdapIsEnableRecord.action",null,
			function(dataObj) {
				if(null != dataObj){
					$("#ldapNote").xtextbox("setValue",dataObj.note);
					$("#ldapPort").xtextbox("setValue",dataObj.port);
					$("#ldapBaseDn").xtextbox("setValue",dataObj.baseDn);
					$("#ldapServerIp").xtextbox("setValue",dataObj.serverIp);
					$("#bindPassword").xtextbox("setValue",dataObj.bindPassword);
					$("#ldapEnable").val(dataObj.enable);
					$("#ldapId").val(dataObj.id);
					flg = true;
				}
			},"json");
	return flg;
}

function ldapServerConfigAdd(){
	$("#ldapId").val("");
	mainObjs.$ldapConfigInfoForm.xform('clear');
	var titleFlg = findLdapRecord();//查询记录回填
	if(titleFlg){
		mainObjs.$ldapConfigInfoWin.xwindow('setTitle','修改LDAP服务配置').xwindow('open');
	}else{
		mainObjs.$ldapConfigInfoWin.xwindow('setTitle','新建LDAP服务配置').xwindow('open');
	}
	$(".form-control").css("borderColor","#cccccc");
	$('input[name="ldapConfigInfoDto.ldapConfigInfo.baseDn"][type="hidden"]').prev().attr("placeholder","例如：uid=user1,ou=People,dc=itest,dc=com");
}
//验证ip
function isValidIP(ip) {
	var reg =/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
    return reg.test(ip);
} 

function saveLdapConfigInfo(){
	var ldapNote = $("#ldapNote").xtextbox("getValue");
	var ldapPort = $("#ldapPort").xtextbox("getValue");
	var ldapBaseDn = $("#ldapBaseDn").xtextbox("getValue");
	var ldapServerIp = $("#ldapServerIp").xtextbox("getValue");
	var bindPassword = $("#bindPassword").xtextbox("getValue");
	
	if(!ldapServerIp){
		 $.xalert({title:'提示',msg:"请填写serverIp!"});
		 return;
	}else{
		var vaildFlg = isValidIP(ldapServerIp);
		if(!vaildFlg){
			 $.xalert({title:'提示',msg:"填写的serverIp格式有问题!"});
			 return;
		}
	}
	
	if(!ldapPort){
		 $.xalert({title:'提示',msg:"请填写端口!"});
		 return;
	}else{
		if(!(/(^[1-9]\d*$)/.test(ldapPort))){
			$.xalert({title:'提示',msg:"填写的端口号必须是数字!"});
		    return;
		}
	}
	
	if(!ldapBaseDn){
		 $.xalert({title:'提示',msg:"请填写baseDn绝对路径!"});
		 return;
	}
	
	if(!bindPassword){
		 $.xalert({title:'提示',msg:"请填写密码!"});
		 return;
	}
	
	var url=baseUrl+"/ldapConfigInfo/ldapConfigInfoAction!saveOrUpdateLdapConfigInfo.action";
	$.ajax({
		  url: url,
		  cache: false,
		  async: false,
		  type: "POST",
//		  dataType:"json",
		  dataType:"text",
		  data: {
			  "ldapConfigInfoDto.ldapConfigInfo.id":$("#ldapId").val(),
			  "ldapConfigInfoDto.ldapConfigInfo.serverIp":ldapServerIp,
			  "ldapConfigInfoDto.ldapConfigInfo.port":ldapPort,
			  "ldapConfigInfoDto.ldapConfigInfo.baseDn":ldapBaseDn,
			  "ldapConfigInfoDto.ldapConfigInfo.bindPassword":bindPassword,
			  "ldapConfigInfoDto.ldapConfigInfo.createPerson":$("#accountId").text(),
			  "ldapConfigInfoDto.ldapConfigInfo.note":ldapNote,
			  "ldapConfigInfoDto.ldapConfigInfo.enable":"1"
		  },
		  success: function(data){
			  if(data.indexOf("success") >=0 ){
				  cancleConfigInfo();
			  }
		  }
		});
	
}

//清除关闭模态窗
function cancleConfigInfo(){
	mainObjs.$ldapConfigInfoForm.xform('clear');
	mainObjs.$ldapConfigInfoWin.xwindow('close');
}
//全局方法，获取表格每一个展示的条数
function getPageSizes(height){
	//93 = 分页高度45+padding8+标题行40
	pageSize =Math.round((height-93)/30);
	pageList = [pageSize,pageSize+20,pageSize+40,pageSize+90];
}

//document.write ('<script type="text/javascript"  src="https://js.users.51.la/19965213.js"></script>');